Modulus

What does "1%2" evaluate to and why? Thanks!
Given two integers a and b, with b ≠ 0, there exist unique integers q and r such that a = bq + r and 0 ≤ r < |b|, where |b| denotes the absolute value of b.

Example: if a = 7 and b = 2, then q = 3 and r = 1, since 7 = 2 × 3 + 1.

The four integers that appear in this theorem have been given a name: a is called the dividend, b is called the divisor, q is called the quotient and r is called the remainder.

Your situation is:

1 = 2 x 0 + 1
So 1 % 2 = 1

That's all.
Last edited on
That was the error in my code then, thanks condor.
Topic archived. No new replies allowed.