Bug #81410 [Opn->Nab]: floatval() add extra precision to certain numbers

From: Date: Fri, 03 Sep 2021 08:37:32 +0000
Subject: Bug #81410 [Opn->Nab]: floatval() add extra precision to certain numbers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236389@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81410&edit=1 ID: 81410 Updated by: nikic@php.net Reported by: mrpramodjodhani at gmail dot com Summary: floatval() add extra precision to certain numbers -Status: Open +Status: Not a bug Type: Bug Package: *General Issues Operating System: MacOC Catalina PHP Version: 8.0Git-2021-09-03 (Git) Block user comment: N Private report: N New Comment: Please make sure you have the serialize_precision ini setting set to the default value of -1. You should never use a different value for serialize_precision. Previous Comments: ------------------------------------------------------------------------ [2021-09-03 08:34:24] mrpramodjodhani at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=81410&edit=1

« previous php.bugs (#236389) next »