php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44255 floating point result 0.0:
Submitted: 2008-02-26 17:58 UTC Modified: 2009-10-08 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: php at jelmer dot cc Assigned:
Status: No Feedback Package: Math related
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
 [2008-02-26 17:58 UTC] php at jelmer dot cc
Description:
------------
Linux version 2.6.22-3-686 (Debian 2.6.22-6) (maks@debian.org) (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 ':')

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-26 18:06 UTC] msaraujo@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


I have not been able to reproduce your code.

PHP 5.2.5
Linux
 [2008-03-05 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-09-30 03:09 UTC] jfafard at gmail dot com
I am also having this problem.  I'm using php version 5.2.4  To reproduce:

echo (0.08 / 0.8);
or
echo (0.04 / 0.4);

pretty much anything like this that should result in 0.1
 [2009-09-30 04:42 UTC] rasmus@php.net
You are really seeing "0.0:" with a colon at the end?  I don't see how that is possible and I certainly can't reproduce it.  Can you please try a current version without any non-php.net extensions and let us know if you still see it.



 [2009-10-08 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC