Math and the modulo (how does those numbers comes up?)


#1

console.log(23 % 10); why the answer is 3?
console.log(99 % 8); why the answer is 3 also?
console.log(11 % 3); why this answer is 2 not 3?
console.log(13 % 7); why this answer is 6 not 2 or 3?

Can someone tell me why this number had been come up different?

Replace this line with your code.


#2

Modulo gives you remaining number ..

See this ^ ten goes into 23 twice and you get remaining 3 thus it prints three


#3

How about console.log(99 % 8)?


#4

console.log(23%10) = 2.3 therefore remainder is 3 right?
but
console.log(99%8)= 12.375? why is 3?
console.log(13%7)= 10.5178571 but comes up 6?


#5

rounds off    


#6

Hi

23 = ( 2 * 10 ) + 3       Here 3 is the remainder
99 = ( 12 * 8 ) + 3       Here 3 is the remainder
11 = ( 3 * 3 ) + 2        Here 2 is the remainder
13 = ( 1 * 7 ) + 6        Here 6 is the remainder

#7

Thank you very much ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)))))))))))))))))))))))))))))))))))))))))


#8

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.