3
Contributors
3
Replies
7
Views
7 Years
Discussion Span
Last Post by donaldw
Featured Replies
  • Modulo 10? eg: 54%10 = 4 Read More

  • [QUOTE=donaldw;1066249]Modulo 10? eg: 54%10 = 4[/QUOTE] TO expand x % 100 will give you the last 2 digits, and x % 1000 will give you last 3 digits, and in general : x % 10^n will give you the last n digits. IN the special case where n = 0, … Read More

  • [QUOTE=firstPerson;1066334]x % 10^n will give you the last n digits. IN the special casewhere n = 0, the result will always be 0, since you ask to get the last "0" digits, which does not make sense.[/QUOTE] Right. Or, mathematically, because the modulo represents the remainder after performing an integer … Read More

1

Modulo 10?

eg:
54%10 = 4

TO expand x % 100 will give you the last 2 digits, and x % 1000 will
give you last 3 digits, and in general :

x % 10^n will give you the last n digits. IN the special case
where n = 0, the result will always be 0, since you ask to get the last "0" digits, which does not make sense.

Edited by firstPerson: n/a

1

x % 10^n will give you the last n digits. IN the special casewhere n = 0, the result will always be 0, since you ask to get the last "0" digits, which does not make sense.

Right. Or, mathematically, because the modulo represents the remainder after performing an integer division, which yields the whole number result of the divison. From my example above:

54/10 = 5 and leaving us with a remainder of 4
54%10 = 4

Any number raised to the 0th power (n^0) is equal to 1. One divides evenly into an whole number, so it never has a remainder. Thus, the result of the modulo operation is always 0:

54/1 = 54 with no remainder
54%1 = 0

Following, OP? :)

This question has already been answered. 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.