Hello Matthew, 3/4 = (0*4)+3 --> 3%4 = 3 9/4 = (2*4)+1 --> 9%4 = 1 20/10 = (2*10)+0 --> 20%10 = 0 4 goes into 3 a total of ZERO times with a remainder of 3. 10 goes into 20 a total of TWO times with a remainder of 0. Take a look at a standard (integer) long division problem with remainders.
-- Best regards, Jason mailto:[EMAIL PROTECTED] Thursday, August 5, 2004, 9:02:04 PM, you wrote: MB> Found some weird behavior in the built in mod function (%): MB> $a = 4; MB> $b = 3; MB> print ( $a % $b ); (returns 1 as it should) MB> Now swap $a and $b: MB> $a = 3; MB> $b = 4; MB> print ( $a % $b ); MB> This returns 3. 3?! 3/4 is 0.75. Shouldn't this return 0? MB> Try this one: MB> $a = 20; MB> $b = 10; MB> print ( $a % $b ); MB> Shouldn't that return 2? It returns 0; MB> $a = 11; MB> $b = 21; MB> print ( $a % $b ); MB> Returns 11. What is going on? Was my C.S. Professor wrong in telling us MB> that the % function returns the left side of the decimal in a division? MB> This is PHP 4.3.4 MB> Any help would be appreciated. MB> Thanks, MB> Matthew MB> -- MB> ---------------------------------------------------------------------------- MB> Matthew Boehm MB> [EMAIL PROTECTED] MB> The University of Texas at Austin, Department of Geography MB> "Why did the prison use Windows2K as a guard? Because it always locks up!" MB> <?PHP echo "PHP kicks ASP!"; ?> MB> ---------------------------------------------------------------------------- -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php