From:             php at jelmer dot cc
Operating system: Linux
PHP version:      5.2.5
PHP Bug Type:     Math related
Bug description:  floating point result 0.0:

Description:
------------
Linux version 2.6.22-3-686 (Debian 2.6.22-6) ([EMAIL PROTECTED]) (gcc
version 4.1.3 20071019 (prerelease) (Debian 4.1.2-17)) #1 SMP Mon Nov 12
08:32:57 UTC 2007

PHP (PHP 5.2.5-2 with Suhosin-Patch 0.9.6.2 (cli) (built: Feb  1 2008
21:17:20)) returns a rather strange result for a certain mathematical
expression. Also, the weird result is only returned in very specific
cases:

php> = (0.005 + 0.002/3 + 0.194 + 0.001/3 )/2
0.0:
(notice the semicolon!)
php> = (0.004 + 0.002/3 + 0.195 + 0.001/3 )/2
0.1
php> = (0.005 + 0.194 + 0.002/3 + 0.001/3 )/2
0.1

When $result is the 'strange' result:
is_float($result) == true
is_float(0.0:) ==> syntax error

Needless to say the strange result is resulting in syntax-errors in the
code where it occurs.

Reproduce code:
---------------
print (0.005 + 0.002/3 + 0.194 + 0.001/3 )/2

Expected result:
----------------
I'd expect:

0.1

Actual result:
--------------
I'm getting:

0.0:

(notice the ':')

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

Reply via email to