From:             dbauleo at terra dot com dot br
Operating system: Windows 2000
PHP version:      4.3.9
PHP Bug Type:     Math related
Bug description:  fmod() does not return the correct value.

Description:
------------
I used the fmod() function with float numbers, and it was an exact
division, so it was supposed to return 0, instead of it, the Y value was
returned.

Reproduce code:
---------------
<?php

  echo fmod(396456.06, 56636.58);

?>

Expected result:
----------------
fmod(396456.06, 56636.58) = 0

Actual result:
--------------
fmod(396456.06, 56636.58) = 56636.58

function f_mod($x,$y)
{
$i = floor($x / $y);
$a = $x - $i * $y;
return $a;
}

f_mod(396456.06, 56636.58) = 0

-- 
Edit bug report at http://bugs.php.net/?id=30330&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30330&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30330&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30330&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30330&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30330&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30330&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30330&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30330&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30330&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30330&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30330&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30330&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30330&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30330&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30330&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30330&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30330&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30330&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30330&r=mysqlcfg

Reply via email to