ruben wrote:
Hi:
Why is the "floor" function returning 27564 instead of 27565 in this
script? PHP version is 4.2.2.
Thanks!
Ruben.
#!/usr/bin/php -q
$b = 275.65 * 100;
$b = (int)$b;
/*
$b was a floating point number with value something like 27564.989,
when displayed it shows correctly
This has to do with the floating point precision.
I quote the manual:
It is quite usual that simple decimal fractions like 0.1 or 0.7 cannot be
converted into their internal binary counterparts without a little loss of
precision. This can lead to confusing results: for example,
floor((0.1+0.7)*10)
2 matches
Mail list logo