Bug #81410 [NEW]: floatval() add extra precision to certain numbers
| From: | mrpramodjodhani at gmail dot com | Date: | Fri, 03 Sep 2021 08:34:24 +0000 |
| Subject: | Bug #81410 [NEW]: floatval() add extra precision to certain numbers | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-236388@lists.php.net to get a copy of this message | ||
From: mrpramodjodhani at gmail dot com
Operating system: MacOC Catalina
PHP version: 8.0Git-2021-09-03 (Git)
Package: *General Issues
Bug Type: Bug
Bug description:floatval() add extra precision to certain numbers
Description:
------------
$num = floatval( 45.34 );
var_dump( $num );
The output of the above script is
float(45.340000000000003)
The same problem happens when I use (float) type convertor.
$num = (float) 45.34;
var_dump( $num );
Test script:
---------------
$num = floatval( 45.34 );
var_dump( $num );
Expected result:
----------------
float(45.34)
Actual result:
--------------
float(45.340000000000003)
--
Edit bug report at https://bugs.php.net/bug.php?id=81410&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81410&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81410&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81410&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81410&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81410&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81410&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81410&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81410&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81410&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81410&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81410&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81410&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81410&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81410&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81410&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81410&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81410&r=mysqlcfg