**And:** If the remainder not 0, then the number must be odd—the remainder would be 0 if it was divisible by 2.

**Correction:** There was something odd about the first implementation of IsOdd on this page. It did not handle negative numbers correctly.

**And:** Fortunately, Joshua Goodman wrote in with the bug report and I corrected the problem.

**So:** If there is no remainder (it returns zero) then the number is definitely even.

**Inlined:** This method could be inlined into the locations you call it without too much loss of clarity.

**Zero:** To learn more about the parity of zero, check out Wikipedia. Zero is an even number.

© 2007-2019 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.

Home

Dot Net Perls