#41106 [Opn]: Simple Expression But Doing Wrong Calculation

From: Date: Mon, 16 Apr 2007 18:05:29 +0000
Subject: #41106 [Opn]: Simple Expression But Doing Wrong Calculation
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-111558@lists.php.net to get a copy of this message
ID: 41106 User updated by: neel dot basu dot z at gmail dot net Reported By: neel dot basu dot z at gmail dot net Status: Open Bug Type: Math related Operating System: Windows -PHP Version: 5.2.1 +PHP Version: 5.1.6 New Comment: I am Using php 5.1.6 Previous Comments: ------------------------------------------------------------------------ [2007-04-16 18:03:16] neel dot basu dot z at gmail dot net Description: ------------ Simple Expression but wrong output. Reproduce code: --------------- <?php $res1 = (1.2-0.1)-1.1;// = 1.1-1.1 -> Evaluates to Zero $res2 = (2.2-0.1)-2.1;// = 2.1-2.1 -> Also Evaluates to Zero echo $res1."\t".gettype($res1); echo "\n"; echo $res2."\t".gettype($res2); ?> Expected result: ---------------- 0 double 0 double Actual result: -------------- -2.22044604925E-016 double 0 double ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41106&edit=1

« previous php.bugs (#111558) next »