Bug #77675 [NEW]: Floating Value Bug
| From: | joni dot ttv at gmx dot de | Date: | Wed, 27 Feb 2019 14:14:06 +0000 |
| Subject: | Bug #77675 [NEW]: Floating Value Bug | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-219754@lists.php.net to get a copy of this message | ||
From: joni dot ttv at gmx dot de
Operating system: Debian, Mac OS
PHP version: 7.2.15
Package: Math related
Bug Type: Bug
Bug description:Floating Value Bug
Description:
------------
Hello,
there is a problem when adding float values:
If you add 76.50 + 15.96 + 7.54 the result ist 100.00. If you var_dump
the sum the result is also 100.00. But when you compare the sum and
100.00 the result is that they are not equal.
If you swap the last two numbers, the sum is correct and also the
comparison.
Test script:
---------------
<?php
// Prints 100
var_dump(76.50 + 15.96 + 7.54);
// Prints false (should be true)
var_dump((76.50 + 15.96 + 7.54) == 100.00);
// Prints false (should be true)
var_dump((76.50 + 15.96 + 7.54) == (76.50 + 7.54 + 15.96));
Expected result:
----------------
100.00
true
true
Actual result:
--------------
100.00
false
false
--
Edit bug report at https://bugs.php.net/bug.php?id=77675&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77675&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77675&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77675&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77675&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77675&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77675&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77675&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77675&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77675&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77675&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77675&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77675&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77675&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77675&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77675&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77675&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77675&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77675&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77675&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77675&r=mysqlcfg