#45278 [Com]: round is not working consitently on 64bit

From: Date: Thu, 19 Jun 2008 10:03:20 +0000
Subject: #45278 [Com]: round is not working consitently on 64bit
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-125882@lists.php.net to get a copy of this message
ID: 45278 Comment by: kontakt at jandreger dot de Reported By: kelfe at gmx dot de Status: Open Bug Type: Math related Operating System: Gentoo64 PHP Version: 5.2.6 New Comment: I can confirm this bug. Server1: (Intel Celeron 2GHz) ============================================= p123:~ # uname -a Linux p123 2.6.24.7-20080507a #1 SMP Wed May 7 10:10:41 CEST 2008 i686 i686 i386 GNU/Linux p123:~ # php -r 'for($i=0;$i<20;$i++) echo round($i+0.015,2)."\n";' 0.02 1.02 2.02 3.02 4.02 5.02 6.02 7.02 8.02 9.02 10.02 11.02 12.02 13.02 14.02 15.02 16.02 17.02 18.02 19.02 p123:~ # php -v PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan 14 2008 17:07:09) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies Server2: (Dual-Core AMD Opteron(tm) Processor 1216 HE) ============================================================ s456:~ # uname -a Linux s456 2.6.24.7-20080507a #1 SMP Wed May 7 10:13:12 CEST 2008 x86_64 x86_64 x86_64 GNU/Linux s1456:~ # php -v PHP 5.2.0 with Suhosin-Patch 0.9.6.1 (cli) (built: Jul 30 2007 15:36:44) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies with the ionCube PHP Loader v3.1.28, Copyright (c) 2002-2007, by ionCube Ltd. s456:~ # php -r 'for($i=0;$i<20;$i++) echo round($i+0.015,2)."\n";' 0.02 1.01 2.02 3.02 4.01 5.01 6.02 7.02 8.02 9.02 10.02 11.02 12.02 13.02 14.02 15.02 16.02 17.02 18.02 19.02 Notebook( Intel(R) Pentium(R) M processor 2.13GHz) =========================================== asd:~$ php -v PHP 5.2.4-2ubuntu5.1 with Suhosin-Patch 0.9.6.2 (cli) (built: May 9 2008 16:34:16) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies asd:~$ uname -a Linux asd 2.6.24-19-generic #1 SMP Wed Jun 4 16:35:01 UTC 2008 i686 GNU/Linux asd:~$ php -r 'for($i=0;$i<20;$i++) echo round($i+0.015,2)."\n";' 0.02 1.01 2.02 3.02 4.01 5.01 6.02 7.02 8.02 9.02 10.02 11.02 12.02 13.02 14.02 15.02 16.02 17.02 18.02 19.02 Previous Comments: ------------------------------------------------------------------------ [2008-06-16 10:20:20] kelfe at gmx dot de Description: ------------ the demo code procduces the expected results on a gentoo 32 bit install (amd 2400+) dev-lang/php-5.2.6-r1 but fails with the actual results on a 64bit install (intel xeon) from the same ebuild the error can reproduced on an older ubuntu PHP 5.2.3 running 64bit as well the loop and sum was only added to reduce the code (could do 20 round of the calculated values as well for the same result) Reproduce code: --------------- php -r 'for($i=0;$i<20;$i++) echo round($i+0.015,2)."\n";' Expected result: ---------------- 0.02 1.02 2.02 3.02 4.02 5.02 6.02 7.02 8.02 9.02 10.02 11.02 12.02 13.02 14.02 15.02 16.02 17.02 18.02 19.02 Actual result: -------------- 0.02 1.01 2.02 3.02 4.01 5.01 6.02 7.02 8.02 9.02 10.02 11.02 12.02 13.02 14.02 15.02 16.02 17.02 18.02 19.02 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45278&edit=1

« previous php.bugs (#125882) next »