From:             edelmar at ditech dot com dot br
Operating system: Win XP
PHP version:      4.3.11
PHP Bug Type:     *Math Functions
Bug description:  floor does not work with some integers as argument

Description:
------------
Using PHP Version 4.3.11 on Windows xp (my development machine).

I believe this behavior of floor function is a bug. The number 7560 passed
to it is an integer and would not be changed by floor.

I am using 100 times number because PHP has no function like 'truncate'. I
want 2 decimals and there is no way to do it with regular functions.

Its like 7560 has some special properties because this error does not
happens with a lot of other numbers.

Thank you.

Reproduce code:
---------------
echo (75.6 * 100).'<br>'; // prints 7560 - OK
echo intval(75.6 * 100).'<br>'; // prints 7559 - ?
echo (int)(75.6 * 100).'<br>'; // prints 7559 - ?
echo floor(75.6 * 100).'<br>'; // prints 7559 - ?
echo ceil(75.6 * 100).'<br>'; // prints 7560 - OK
echo round(75.6 * 100).'<br>'; // prints 7560 - OK



Expected result:
----------------
7560
7560
7560
7560
7560
7560

Actual result:
--------------
7560
7559
7559
7559
7560
7560

-- 
Edit bug report at http://bugs.php.net/?id=33009&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33009&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33009&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33009&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33009&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33009&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33009&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33009&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33009&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33009&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33009&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33009&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33009&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33009&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33009&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33009&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33009&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33009&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33009&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33009&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33009&r=mysqlcfg

Reply via email to