Bug #17772 Updated: round() not rounds as expected
| From: | george at intellnet dot net dot uk | Date: | Mon, 15 Jul 2002 12:54:52 +0000 |
| Subject: | Bug #17772 Updated: round() not rounds as expected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-14199@lists.php.net to get a copy of this message | ||
ID: 17772
Updated by: george@intellnet.net.uk
Reported By: carlos@wfmh.org.pl
Status: Bogus
Bug Type: *Math Functions
Operating System: Linux GNU/Debian
PHP Version: 4.1.2
New Comment:
No,
This is a platform specific build/optimization issue not a float
precision "bogus bug".
Compile ext/standard/math.c without optimization i.e.
with -O0 instead of -O2, and the bug vanishes:
gcc -I. -I/home/george/php-4.2.1/ext/standard
-I/home/george/php-4.2.1/main -I/home/george/php-4.2.1
-I/home/george/php-4.2.1/Zend
-I/home/george/php-4.2.1/ext/mysql/libmysql
-I/home/george/php-4.2.1/ext/xml/expat -I/home/george/php-4.2.1/TSRM
-g -O0 -c math.c && touch math.lo
(php 4.1.2 i386-pc-linux-gnu Debian Linux test 2.2.18pre21)
I believe BSD always works.
For an even simpler test case, try round(0.35,1);
George
Previous Comments:
------------------------------------------------------------------------
[2002-06-15 12:52:02] hholzgra@php.net
see the note on float precision on
http://www.php.net/manual/en/language.types.float.php
------------------------------------------------------------------------
[2002-06-15 10:10:50] carlos@wfmh.org.pl
round(12.555, 2) produces 12.55 not 12.56 as is documented (and as it
should). round(12.556, 2) works fine thou.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17772&edit=1