On 10/13/2010 11:14 PM, Glen Fuller wrote:
On 10/13/2010 10:48 PM, Mattias Thorslund wrote:
Hi List,
I'm having a problem with the behavior of the floor() function:
echo floor(327.03 * 100)."\n"; //prints "32702" and not "32703"!!
Sanity check:
var_dump(327.03 * 100); //prints "float(32703)" as expected
Any ideas why this happens, and how to work around it?
Thanks,
Mattias
Wouldn't that be equivalent to floor(32703), and since 32703 is the
nearest integer to 32703 it returns it?
Glen Fuller
Nope, this is floating-point math fuzziness. Try it:
echo floor(32703)."\n";
echo floor(327.03 * 100)."\n";
Cheers,
Mattias
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php