Bug #62170 [Opn]: Inaccurate division
| From: | cidahf at live dot co dot uk | Date: | Sun, 27 May 2012 05:14:47 +0000 |
| Subject: | Bug #62170 [Opn]: Inaccurate division | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-170855@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62170&edit=1
ID: 62170
User updated by: cidahf at live dot co dot uk
Reported by: cidahf at live dot co dot uk
Summary: Inaccurate division
Status: Open
Type: Bug
Package: Math related
Operating System: Ubuntu 12.04
-PHP Version: 5.4.3
+PHP Version: 5.4.3-4~precise+1
Block user comment: N
Private report: N
New Comment:
Changed the version to the exact value returned from PHP_VERSION.
Previous Comments:
------------------------------------------------------------------------
[2012-05-27 05:01:08] cidahf at live dot co dot uk
Description:
------------
When I divide 25.4 by 10000 I get an awkward
0.002539999999999999723276911112179732299409806728363037109375 instead of the
desired 0.00254. I tried the same with Ruby 1.8.7 and it returned the correct
result.
This issue is problematic for unit conversion.
I also got this in 5.3 but I upgraded before making a report.
Test script:
---------------
echo 25.4 / 10000;
Expected result:
----------------
0.00254
Actual result:
--------------
0.002539999999999999723276911112179732299409806728363037109375
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62170&edit=1