Found some weird behavior in the built in mod function (%):

$a = 4;   
$b = 3;   
print ( $a % $b );  (returns 1 as it should)

Now swap $a and $b:

$a = 3;   
$b = 4;   
print ( $a % $b );

This returns 3. 3?! 3/4 is 0.75. Shouldn't this return 0?

Try this one:

$a = 20;  
$b = 10;  
print ( $a % $b );

Shouldn't that return 2? It returns 0;

$a = 11;  
$b = 21;  
print ( $a % $b );

Returns 11.  What is going on?  Was my C.S. Professor wrong in telling us
that the % function returns the left side of the decimal in a division?

This is PHP 4.3.4

Any help would be appreciated.

Thanks,
Matthew
-- 
----------------------------------------------------------------------------
Matthew Boehm
[EMAIL PROTECTED]
The University of Texas at Austin, Department of Geography

"Why did the prison use Windows2K as a guard? Because it always locks up!"
<?PHP echo "PHP kicks ASP!"; ?>
----------------------------------------------------------------------------

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to