Page 1 of 1

Detecting Remainders

Posted: Tue May 23, 2006 4:15 pm
by BigAbe
Is there a function to determine remainders? I'm fully aware of round(), ceil(), and floor(), but is there something to determine if a division equation has a remainder?

Thanks!

-- Abe --

Posted: Tue May 23, 2006 4:25 pm
by BigAbe
Until someone can let me know of any functions for remainders, I whipped this one up to share with everyone...

Code: Select all

for ($num = 1; $num < 23; $num++){
	$r = $num/10;
	$q= number_format($r);
	echo $q;
	if (($r - $q) == 0)
		print ("The number \"$num\" is divisible by 10.<br>");
	else
		print ("The number \"$num\" is NOT divisible by 10.<br>");
	
		
}
Hope this can help someone.

-- Abe --

Posted: Tue May 23, 2006 4:29 pm
by BigAbe
Or you can totally ignore my post and hit me upside the head for totally forgetting the precious mod entity...

Stupid me...

Code: Select all

for ($num = 1; $num < 23; $num++){
	if (($num%10) == 0)
		print ("The number \"$num\" is divisible by 10.<br>");
	else
		print ("The number \"$num\" is NOT divisible by 10.<br>");
}
I should really eat my Wheaties before I code in the morning...

-- Abe --