Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
basically i have this sum

(11+22+33+44+55) % 26

what does the %26 mean?

i've tried 165 divided by 26 which gives me 6.3

percentage equals the same... can anyone help?

forgive me if this a stupidly idiotic question to ask
Posted
Updated 18-Jan-14 23:41pm
v2

Percent is the C# Modulus operator: MDSN[^] - it returns the remainder when the left side is divided by the right, and returns it as an integer.

So:
C#
12 % 10 == 2
12 %  8 == 4

And
C#
(11+22+33+44+55) % 26 == 165 % 26 == 9



[edit]Typo: transposed digits - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
Member 10506451 19-Jan-14 5:54am    
hmmm so its not a simple division then.. when i tried to divide 165 by 26 on the calculator it gives me 6.34615385
OriginalGriff 19-Jan-14 6:09am    
Correct!
165 / 26 == 6.34615385
Subtract the whole number:
0.34615385
Multiply by 26 again:
0.34615385 * 26 = 9
So
165 / 26 == 6 and 9/26ths as a fraction.
Or, if you divide 165 by 26, it goes 6 times, with a remainder of 9:
6 * 26 == 156
165 - 159 == 9
That's what a modulus operator does: returns the remainder of the division.
Its really handy if you want to convert an integer into it's separate digits: take the modulus by 10 ( which returns the lowest digit). Then integer divide the original number by 10. If it isn't zero, there are more digits, so do it again with the result of the division.
CPallini 19-Jan-14 8:02am    
It is the reminder of the integer division.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900