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

From: Date: Mon, 16 Apr 2007 18:07:28 +0000
Subject: #41106 [Opn->Fbk]: Simple Expression But Doing Wrong Calculation
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-111559@lists.php.net to get a copy of this message
ID: 41106 Updated by: helly@php.net Reported By: neel dot basu dot z at gmail dot net -Status: Open +Status: Feedback Bug Type: Math related Operating System: Windows PHP Version: 5.1.6 New Comment: Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.2-win32-latest.zip Previous Comments: ------------------------------------------------------------------------ [2007-04-16 18:05:29] neel dot basu dot z at gmail dot net I am Using php 5.1.6 ------------------------------------------------------------------------ [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 (#111559) next »