#45094 [Opn->Bgs]: wrong return of round()

From: Date: Mon, 26 May 2008 20:02:48 +0000
Subject: #45094 [Opn->Bgs]: wrong return of round()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-125271@lists.php.net to get a copy of this message
ID: 45094 Updated by: jani@php.net Reported By: webmaster at tsgames dot de -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Windows XP PHP Version: 5.2.6 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. If you would like to know more about "floats" and what IEEE 754 is, read this: http://docs.sun.com/source/806-3568/ncg_goldberg.html Thank you for your interest in PHP. Previous Comments: ------------------------------------------------------------------------ [2008-05-26 17:38:13] webmaster at tsgames dot de Description: ------------ Function round() returns a wrong value ("-0") when the real value is lower than 0. Reproduce code: --------------- <? echo "Value: ".round(-0.0001,0); ?> Expected result: ---------------- Value: 0 Actual result: -------------- Value: -0 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45094&edit=1

« previous php.bugs (#125271) next »