From:             bruno dot boccara at d2b dot com
Operating system: windows 2003 Apache 2
PHP version:      4.4.5
PHP Bug Type:     Math related
Bug description:  round function

Description:
------------
round function gives wrong value.

Please do not send me to
http://docs.sun.com/source/806-3568/ncg_goldberg.html, you have to admit
that this is a bug !!!!!
if not, php CANNOT be use in production site with mathematical functions
!!!

Reproduce code:
---------------
<?
// 140.25*(1-(34/100)) = 92.565


echo "formula = ". round(((140.25*(1-(34/100)))),2);echo "<br>";

echo "direct = ".round (92.565, 2);echo "<br>";

$valeur = 140.25*(1-(34/100));

echo "value = ".round($valeur,2);echo "<br>";

settype($valeur,"string");
settype($valeur,"float");

echo "value2 = ".round($valeur,2);

?>

Expected result:
----------------
formula = 92.57
direct = 92.57
value = 92.57
value2 = 92.57

Actual result:
--------------
formula = 92.56 // WRONG !
direct = 92.57
value = 92.56  // WRONG !
value2 = 92.57

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

Reply via email to