Bug #68375 [Com]: function floatval

From: Date: Thu, 28 Jan 2016 12:55:10 +0000
Subject: Bug #68375 [Com]: function floatval
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198945@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68375&edit=1 ID: 68375 Comment by: spam2 at rhsoft dot net Reported by: brulik at kdv dot cz Summary: function floatval Status: Not a bug Type: Bug Package: Variables related Operating System: linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: that is nonsense-behavior, there is no sane reason for defaulting to scientific notation and at least strval() should convert it back "number_format" generates a fixed count of decimals strval(doubleval('0.00001')) results in "1.0E-5" have fun sanitize vars for generate SpamAssassin rules with PHP "FREEMAIL_SUBJECT 1.0E-5" is not valid for "score", skipping: score FREEMAIL_SUBJECT 1.0E-5 Previous Comments: ------------------------------------------------------------------------ [2014-11-07 16:35:47] nikic@php.net The default float -> string cast uses scientific notation if the resulting output is shorter than printing the number directly (%g printf modifier). If you want to control the exact output, either use number_format or sprintf. ------------------------------------------------------------------------ [2014-11-07 13:27:49] brulik at kdv dot cz Description: ------------ Hello, I found a problem when using function floatval. Problem occurs in five digit numbers. Processed data is variously evaluates. Test script: --------------- $number='0.00001'; $number2='1.00001'; echo floatVal($number); echo "</ br>"; echo floatVal($number2); Expected result: ---------------- 1.0E-5 1.00001 Why is the first value of 1.0E-5 instead of values 0.00001 ? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68375&edit=1

« previous php.bugs (#198945) next »