go to previous page   go to home page   go to next page

Answer:

0 or 1

N mod 2 is 0 if N is even.

N mod 2 is 1 if N is odd.


Integer Divide by Two

integer division by two

For example:

23 div 2 = 11
23 mod 2 = 1

div means integer division. mod means the remainder after integer division (also called modulo division).

Because 23 is odd, you know that its binary representation ends with a 1. The mod operation picks out this fact.


QUESTION 2:

What is 24 mod 2?

Does the binary representation of 24 end with a 1 or with a zero?


go to previous page   go to home page   go to next page