Bug #17772 Updated: array_merge() throws warning when supplied with 1 argument only
| From: | george at intellnet dot net dot uk | Date: | Tue, 16 Jul 2002 10:08:07 +0000 |
| Subject: | Bug #17772 Updated: array_merge() throws warning when supplied with 1 argument only | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-14298@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:
Switching off inline maths, (-D__NO_INLINE_MATHS), but leaving
optimisation (-02), also solves this problem.
My guess as to what is going on is:
With inline maths, the value used on the floor() in round is coming
straight from the fpu's register, not from memory. The register is
wider than a double and contains spurious precision left over from the
previous multiply, so the floor fp operation is carried out on the
"wrong" number. Without inline maths, the library floor() function is
called so the operand comes out of the register and back into double
format.
This fits in with the observation that inserting trace or other code
between the multiply and floor also solves the problem.
If I'm right, the simple solution is to switch off in line maths, i.e.
-D__NO_INLINE_MATHS. For safety, this might need to be a general
option across all compiles on Intel platforms.
I'm going to try checking my diagnosis with a specialist newsgroup....
George Whiffen
Previous Comments:
------------------------------------------------------------------------
[2002-07-15 09:02:43] carlos@wfmh.org.pl
So it's rather Makefile issue? Or it shall be reported to Debian
package maintainer then?
------------------------------------------------------------------------
[2002-07-15 08:54:51] george@intellnet.net.uk
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
------------------------------------------------------------------------
[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