Detecting Remainders

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BigAbe
Forum Commoner
Posts: 66
Joined: Fri Mar 31, 2006 7:41 pm

Detecting Remainders

Post 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 --
BigAbe
Forum Commoner
Posts: 66
Joined: Fri Mar 31, 2006 7:41 pm

Post 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 --
BigAbe
Forum Commoner
Posts: 66
Joined: Fri Mar 31, 2006 7:41 pm

Post 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 --
Post Reply