I have an ojbect $order
that has a member function amount()
that adds up the sum of the line items (all floats) then returns the value (again, as a float).
var_dump(array(
$order->amount() * 100.0,
intval($order->amount() * 100.0),
));
result:
Array
(
[0] => 7500
[1] => 7499
)
The values of the line items are all under 1000 and never have more than 2 decimal points...
What is the best way to deal with decimal values in PHP, since the lack of precision is causing problems for me...
EDIT: To better illustrate:
echo "Addition: " . intval((172.45 - 72.45 - 25.0) * 100);
Result:
Addition: 7499