+ 17
How does the modulo operator works ?
I don't understand how this operator works.
2 Answers
+ 5
If we divide 1.25 by .5 than, we can write:
1.25= .5*2(here .5*2=1)+.25 (here .25 is remainder, here further division approaches not followed as normal mathematical process follows, in normal mathematical process, we can write 1.25/.5 = 2.5)
hence,
1.25 divided by .5, quotient is 2 and .25 isn't divided by .5 so it is remainder.
above term is expressed by modulus sign (%),where % shows only remainder,not shows quotient.
it is expressed by
5%2 = 1
11%4 = 3
5%3 = 2
3%5 = 3
6%5 = 1
12%7 = 5
2%2 = 0
1.25%.5 = .25
+ 5
Every integer can be expressed like this
N=Qk+R(0=<R<k)
N is the number k is the number divided Q is the value multiplied by k and R is the REMAINDER.
N/k returns the Q
N%k returns the R
%can be made by
A%B=A-A/B*B
Hope this makes you understand more :)