Simple question: Why this behavior:
var_dump($calc_product);
var_dump($calc_price);
var_dump(round($calc_product,1));
var_dump(round($calc_price,1));
gives:
float(16.05) float(16.05) float(16) float(16.1)
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Don’t use floats for money.
A common method is to store the price in pence/cents, then to divide by 100 on display. This means you can use integer arithmetic instead, and avoids this issue.