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

**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.

**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.

Home

Dot Net Perls

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