|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-08-26 19:59 UTC] zoxx at konto dot pl
Description: ------------ Bug related with Bugs #41811, #41152. It's not really round() problem but string conversion made by echo or concatenation with string. It is serious bug with strong consequences: - php4 was free with that 'feature' so old correctly working scripts could fail with php5 - data that is inserted to mysql with exponent notation to mysql integer fields is cutted to digits (so if you insert 1.41E+7 '1' integer is inserted instead) - data could be not displayed correctly, not correctly inserted to files or passed to external systems (and so on...) - it is unrelated with 'precision' php.ini configuration item, so unexpected by programmer Reproduce code: --------------- <form action="testval.php" method=POST> <input type=text name=val> </form> <?php echo $val*100.0; ?> Expected result: ---------------- input: 410000 output: 41000000 Actual result: -------------- input: 410000 output: 4.1E+7 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 02:00:02 2025 UTC |
fine.. but it wasn't documentation problem Anyway we have solved it in our scripts, where it was most urgent, by adding special function to convert strings that may contain exponental numbers because this bug - eg. before sending query to mysql (it was easy because we have special class to call databases, but if you use mysql_something functions everywhere you are lucky less...): /** * function ConvExponent($str) * This function replaces exponent notation of float values in string */ function ConvExponent($str) { return preg_replace('#(\d+)\.(\d+)E(\+|\-)(\d+)#sie', 'sprintf(\'%F\',floatval($0))', $str); }