#26954 [Opn->Bgs]: 0.1 - 01 = -2.77555756156E-017

From: Date: Sun, 18 Jan 2004 15:00:44 +0000
Subject: #26954 [Opn->Bgs]: 0.1 - 01 = -2.77555756156E-017
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-53522@lists.php.net to get a copy of this message
ID: 26954 Updated by: derick@php.net Reported By: choikh at oms dot cc -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: window, linux PHP Version: 4.3.4 New Comment: Floating point values have a limited precision. Hence a value might not have the same string representation after any processing. That also includes writing a floating point value in your script and directly printing it without any mathematical operations. Thank you for your interest in PHP. / Previous Comments: ------------------------------------------------------------------------ [2004-01-18 09:54:49] choikh at oms dot cc Description: ------------ bug sample <? $tot = 0.3; for($i=0;$i < 3; $i++) { echo("==> $tot, "); $tot -= 0.1; echo("==> $tot<br>"); } ?> result ==> 0.3, ==> 0.2 ==> 0.2, ==> 0.1 ==> 0.1, ==> -2.77555756156E-017 why ? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26954&edit=1

« previous php.bugs (#53522) next »