Bug #62170 [Opn]: Inaccurate division
Edit report at https://bugs.php.net/bug.php?id=62170&edit=1
ID: 62170
Updated by: laruence@php.net
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-4~precise+1
Block user comment: N
Private report: N
New Comment:
float is inaccurate, http://cn.php.net/manual/en/language.types.float.php
Previous Comments:
------------------------------------------------------------------------
[2012-05-27 05:14:47] cidahf at live dot co dot uk
Changed the version to the exact value returned from PHP_VERSION.
------------------------------------------------------------------------
[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
Thread (5 messages)