|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-11-07 13:27 UTC] 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 ? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 02:00:01 2025 UTC |
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-5oh yeah use sprintf sprintf("%g", $out); 1.0e-5 sprintf("%01.5", '0.000001'); 0 sprintf("%01.10", '0.00001'); 0