I've got the following script which demonstrates a problem I'm having with floating point numbers and intval:

$times100 = (-37.12 * 100);
print $times100 . "\n";

$intval100 = intval($times100);
print $intval100 . "\n";

print ($intval100 / 100) . "\n";

I expect the output to be:

However, the actual output I'm getting (on several systems, so it's not just my machine) is:

Is there a reason for this, and a better way I should be doing it? Basically I need to add up a list of floats, representing currency values, and see if they're equal to another float, but I need to convert them to ints first because I can't guarantee than there won't be something after the second decimal place.



Paul Waring

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to