#26874 [Opn->Bgs]: round floting number have bad result

From: Date: Mon, 12 Jan 2004 11:17:22 +0000
Subject: #26874 [Opn->Bgs]: round floting number have bad result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-53165@lists.php.net to get a copy of this message
ID: 26874 Updated by: eru@php.net Reported By: yehlu at ms1 dot hinet dot net -Status: Open +Status: Bogus Bug Type: *Math Functions Operating System: 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-12 01:48:14] yehlu at ms1 dot hinet dot net Description: ------------ <?php $a = 3100; echo "\$a :".$a."\n"; $a *= 1.025; echo "\$a * 1.025 :".$a."\n"; echo "round \$a:".round($a)."\n"; //get 3177 echo "round \$a:".round("$a")."\n"; //get 3178 $b = "3177.5"; echo "\$b:".$b."\n"; echo "round \$b:".round($b)."\n"; //get 3178 ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26874&edit=1

« previous php.bugs (#53165) next »