|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-07-13 00:35 UTC] brunog at micro-examples dot com
Description:
------------
PHP Version => 5.2.4-2ubuntu5.10
can you please consider this short code ?
Test script:
---------------
<?php
$f1 = 0.09 ;
$f2 = 0.01 ;
$tot = $f1 + $f2 ;
echo("$tot\n") ;
?>
Expected result:
----------------
0.1
Actual result:
--------------
0.0:
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 23:00:01 2025 UTC |
prints 0.1 for me. You are probably hitting a floating point limitation combined with a precision setting problem in your environment. Try adding ini_set('precision',16); to the top of your script and you will see.thank you for the quick reply adding ini_set('precision',16); does not give correct result value : 0.09999999999999999 is it an echo() bug ? 0.0: is lexicographically before 0.1 0.09 + 0.01 = 0.0: is correct ascii saying