#43572 [Opn->Fbk]: fmod($a,$b) wrong when $b is a multiple of $a
| From: | jani@php.net | Date: | Wed, 12 Dec 2007 09:52:14 +0000 |
| Subject: | #43572 [Opn->Fbk]: fmod($a,$b) wrong when $b is a multiple of $a | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-120596@lists.php.net to get a copy of this message | ||
ID: 43572
Updated by: jani@php.net
Reported By: csaba at alum dot mit dot edu
-Status: Open
+Status: Feedback
Bug Type: Math related
Operating System: Win XP
PHP Version: 5.2.5
New Comment:
Try this with CLI:
php -n -r 'echo fmod(9.75,1.625);'
Previous Comments:
------------------------------------------------------------------------
[2007-12-12 09:51:33] jani@php.net
Works fine for me on Linux.
------------------------------------------------------------------------
[2007-12-12 00:55:39] csaba at alum dot mit dot edu
Description:
------------
if $div evenly divides $num, fmod($num, $div) still returns a value not
equal to 0 for almost all decimal $div, where the decimal portion is not
n/2^k for some n and k.
e.g.
fmod(9.75,1.625) => 0 because .125 is 5/2^3
Expected result:
----------------
I expect to see fmod return 0 when the 1st argument is a multiple of
the 2nd.
Csaba Gabor from Vienna
Actual result:
--------------
fmod(6.5, 1.3) => 1.3
which is incorrect
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43572&edit=1