Bug #67978 [NEW]: Bug with floating number
| From: | tripollite at gmail dot com | Date: | Mon, 08 Sep 2014 12:47:17 +0000 |
| Subject: | Bug #67978 [NEW]: Bug with floating number | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-187446@lists.php.net to get a copy of this message | ||
From: tripollite at gmail dot com
Operating system: Debian 7
PHP version: Irrelevant
Package: *Math Functions
Bug Type: Bug
Bug description:Bug with floating number
Description:
------------
Var dump fail to show right number but this number is used in memory to
make calcul.
it should respect precision by cutting floating numbers
or showing the right number
Test script:
---------------
http://3v4l.org/AFQF6
<?php
$b = 0.27*28;
$a = round($b,2);
var_dump($a-$b);
$b = 0.270000000000001;
$a = round($b,2);
var_dump($b);var_dump($a-$b);
Expected result:
----------------
float(0)
float(0.27)
float(0)
Actual result:
--------------
float(-8.8817841970013E-16)
float(0.27)
float(-9.9920072216264E-16)
--
Edit bug report at https://bugs.php.net/bug.php?id=67978&edit=1
--