Bug #81410 [Com]: floatval() adds extra precision to certain numbers

From: Date: Fri, 03 Sep 2021 09:00:23 +0000
Subject: Bug #81410 [Com]: floatval() adds extra precision to certain numbers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236391@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 Comment by: mrpramodjodhani at gmail dot com Reported by: mrpramodjodhani at gmail dot com Summary: floatval() adds extra precision to certain numbers 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: Hello nikic@php.net, Thank you! It solved the problem. I think the problem is with LocalWP which I'm using. I will send them a mail regarding this. Thanks again for your help. Previous Comments: ------------------------------------------------------------------------ [2021-09-03 08:43:53] mrpramodjodhani at gmail dot com updated title ------------------------------------------------------------------------ [2021-09-03 08:37:32] nikic@php.net 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. ------------------------------------------------------------------------ [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 (#236391) next »