0

I know that it returns the remainder but what happens when say :

x% y,

where x,y is int and x<y. I see that results in x;

For example, 3% 101232 = 3 and similarly 3%y, where y is
greater than 3 yields 3. Why is that>

Just wonder the details of what goes on.

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by chaines51
0

There is no integer modulo instruction so one method to calculate a modulo is

y = F( a mod c )
-------
d = a / c
y = a - (c * d)
-------
if ( a < c ) then d = 0
y = a - (c * 0)
y = a - 0
y = a

0

Also, if you think about it, it is still returning the remainder.

3/4 is .75, or 0 r 3.
the same applies for all numbers greater than three.
ie
3/5 is .6 or 0 r 3.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.