Hello,

My understanding from the documentation is that the fmod() function should
work with floating point numbers however the following snippet of code:

<?php
//php 4.3 on Linux

$x = 1.05;
$y = 0.05;

echo "x: $x <br>";
echo "y: $y <br>";
echo "fmod: " . fmod($x, $y) . "<br>";

?>

outputs the following:

x: 1.05
y: 0.05
fmod: 0.05

I would have expected to get an answer of 0 i.e. no remainder. It works fine
for whole numbers.

Can any one shed any light on this please?

Thank you.

Regards,
Andy

P.S. I tried using the following function but I get the same results:

function fmodAddOn($x,$y)
{
       $i = floor($x/$y);

       // r = x - i * y
       return $x - $i*$y;
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to