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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.