#42294 [Opn->Asn]: round will not use PHP_ROUND_FUZZ on 64bit CPUs
| From: | jani@php.net | Date: | Thu, 16 Aug 2007 11:39:05 +0000 |
| Subject: | #42294 [Opn->Asn]: round will not use PHP_ROUND_FUZZ on 64bit CPUs | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-116167@lists.php.net to get a copy of this message | ||
ID: 42294
Updated by: jani@php.net
Reported By: oliver at teqneers dot de
-Status: Open
+Status: Assigned
Bug Type: *Configuration Issues
Operating System: OpenSuSE 10.2
PHP Version: 5.2.4RC1
-Assigned To:
+Assigned To: iliaa
New Comment:
Assigned to Ilia who implemented that PHP_ROUND_FUZZ.
Previous Comments:
------------------------------------------------------------------------
[2007-08-16 11:34:25] oliver at teqneers dot de
you might use a windows machine? there the fuzzy seems to be always
turned off (I don't know why though???).
math.c:
-------
#ifndef PHP_ROUND_FUZZ
# ifndef PHP_WIN32
# define PHP_ROUND_FUZZ 0.50000000001
# else
# define PHP_ROUND_FUZZ 0.5
# endif
#endif
But I have to admit, that I forgot to switch to the php5 versions on
our 32bit server. So on all our PHP4 versions with 32bit, round seems to
work as mathematically expected. Sorry for that.
BUT still the result could be correct with PHP_ROUND_FUZZ on, like it
did with PHP4. I compiled the latest PHP5 (5.2.4RC1) and changed the
configure check to be more precise. After that the round was working
much better, than it did before. My current result with the patched
configure script is:
0.285 - 0.29
1.285 - 1.29
1.255 - 1.26
I mean, why is the FUZZ implemented and not used???
------------------------------------------------------------------------
[2007-08-16 10:30:57] jani@php.net
Output for me on a 32bit system:
0.285 - 0.28
1.285 - 1.29
1.255 - 1.25
------------------------------------------------------------------------
[2007-08-16 10:29:52] jani@php.net
Those results you get are NOT incorrect. If you round using 2 decimals,
of course that's what you get.
------------------------------------------------------------------------
[2007-08-15 11:25:09] oliver at teqneers dot de
this is an example of the comment block of the round documentation
(http://de.php.net/manual/en/function.round.php):
<?php
printf("0.285 - %s <br> ",round(0.285,2));
// incorrect result 0.28
printf("1.285 - %s <br> ",round(1.285,2));
// correct result 1.29
printf("1.255 - %s <br><br>",round(1.255,2));
// incorrect result 1.25
?>
------------------------------------------------------------------------
[2007-08-15 08:47:36] jani@php.net
Can you please provide a short PHP code example which fails because of
this..?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/42294
--
Edit this bug report at http://bugs.php.net/?id=42294&edit=1