# Help ! to evalute 1 % 10 ?

This is a discussion on Help ! to evalute 1 % 10 ? within the C Programming forums, part of the General Programming Boards category; 1234 % 10 = 4 (4 is the reminder when 1234 is divided by 10) 156 % 10 = 6 ...

1. ## Help ! to evalute 1 % 10 ?

1234 % 10 = 4 (4 is the reminder when 1234 is divided by 10)
156 % 10 = 6
12 % 10 = 2

i could understand how the value of above expression is evaluated but
i couldn't figure out how to determine the value of these expression

9 % 10 = ?
1 % 10 = ?

2. Divide normally, save the remainder as your answer. Incidentally this is true for all modulo problems.

3. ^^ what whiteflags said. This is just modulo arithmetic -- which is well defined. 9 doesn't divide by 10 even once so the remainder is 9. -1 is also correct, but C and C++ will give you the positive answer if you pass in 2 positive numbers.

4. 9 % 10 = 9
1 % 10 = 1

5. u can broaden ur concept by knowing that

-9 % 10 = -9
-1 % 10 = -1
-11 % 10 = -1

6. Originally Posted by smokeyangel
-1 is also correct...
divident = divisor*quotent + remainer <==>
remainer = divident - divisor*quotent

divident = 9
divisor = 10
quotent = 0

remainer = 9 - 10*0 = 9

I'm curious to see your explanation why you think -1 is also correct.

7. Originally Posted by GReaper
divident = divisor*quotent + remainer <==>
remainer = divident - divisor*quotent

divident = 9
divisor = 10
quotent = 0

remainer = 9 - 10*0 = 9

I'm curious to see your explanation why you think -1 is also correct.
cuz if u add 1 to 9 u get 10 (which is divisible by 10....10%10=0)
so, in mathematics we use two conventions...
9%10 = 9
also
9%10= -1

but C deals with only one aspect..(only the positive one...it doesn't cares about pure mathematics )

8. Originally Posted by rajarshi
9 % 10= 9
also
9 % 10= -1
Show me one practical application of that (second) convention.
I've never seen (9% 10 =-1) anywhere .

but C deals with only one aspect..
C deals with what you make it deal with.

9. Originally Posted by manasij7479
Show me one practical application of that (second) convention.
I've never seen (9% 10 =-1) anywhere .

C deals with what you make it deal with.

there is a convention...to can pick up any higher mathematics number theory book and u can find it...

well the practical application is like this...
think of a clock..the clocks' entire clock surface is divided in 12 parts....suppose u have ur dinner at 10....and now the clock points at 9....so for the clock to point at 10...either it has to so 9 units backward or 1 unit forward....in both cases it points at 10 ...
and now u can have ur dinner !!

10. Originally Posted by rajarshi
think of a clock..the clocks' entire clock surface is divided in 12 parts....suppose u have ur dinner at 10....and now the clock points at 9....so for the clock to point at 10...either it has to so 9 units backward or 1 unit forward....in both cases it points at 10 ...
That somewhat makes sense.
But the clock is circular....but the number line isn't.
So.. couldn't calculations potentially be off by the numerical value of the divisor when an ambiguity exists?

11. Originally Posted by manasij7479
That somewhat makes sense.
But the clock is circular....but the number line isn't.
So.. couldn't calculations potentially be off by the numerical value of the divisor when an ambiguity exists?
number line is not circular...
but the mod operator when implemented on the number line performs the particular action on a circular path...
like while using a mod operator..
0 1 2 3 4 5 6 7 8 9 and again 0 (similar to the clock analogy)

don't consider the calculations only one way...
here goes the calculations

9%10=9 (convention 1)
OR
9%10= -1 (convention 2)

so u can write

0*10 + 9 = 9 (convention 1)
OR
0*10 + (10-1) = 9 (convention 2)

convention 2 , I am using (10-1) as we know that we are performing the calculations on a %10
u get get to know what was the divisor by looking at the (0*10) part !!

12. That's bulls**t! Here we're talking about absolute numbers, not void mathematical theories. If you take the formula I gave and use it correctly you'll see that what you say is impossible.

13. Originally Posted by GReaper
Here we're talking about absolute numbers, not void mathematical theories. If you take the formula I gave and use it correctly you'll see that what you say is impossible.
smokeyangel and rajarshi are correct to say that 9 is congruent to -1 modulo 10. The confusion is that % is often called the modulo operator, but it would be more accurate to call it the remainder operator. That said, given smokeyangel's caveat about the context of C and C++, I do not find smokeyangel to be wrong. rajarshi's use of the clock analogy is a common way to explain modular arithmetic, which is sometimes called clock arithmetic.

14. Originally Posted by GReaper
That's bulls**t! Here we're talking about absolute numbers, not void mathematical theories. If you take the formula I gave and use it correctly you'll see that what you say is impossible.
This isn't bulls**t...this is pure number theory in mathematics !!

15. Originally Posted by rajarshi
u can broaden ur concept by knowing that

-9 % 10 = -9
-1 % 10 = -1
-11 % 10 = -1
If you mean C, the answer has the sign of the divisor not the dividend.

Page 1 of 2 12 Last