From:             rbro at hotmail dot com
Operating system: Linux
PHP version:      5CVS-2007-10-05 (snap)
PHP Bug Type:     BC math related
Bug description:  bcmath incorrect results / number format

Description:
------------
When adding certain floating point numbers together using bcadd (or using
the other bcmath functions), I'm receiving invalid results at times
depending on the inputs.  It appears that with recent PHP releases, PHP is
expressing certain floating point numbers in scientific notation which
bcmath is not correctly handling.  Using my example below, PHP is
expressing the number 1200000.00 as 1.2E+6 which is causing incorrect
results from bcadd.


Reproduce code:
---------------
<?php
bcscale(2);
echo bcadd(1200000, 1)."\n";
echo bcadd(1200000.00, 1)."\n";


Expected result:
----------------
1200001.00
1200001.00


Actual result:
--------------
1200001.00
1.00


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

Reply via email to