Potential Pitfalls in Java's Modulo Operator for Parity Checking
A common approach for determining if a integer is odd or even in Java is to use the modulo operator %. While this often works, a subtle bug can occur with ngeative numbers. Demonstrating the Issue Consider the following test method: @Test public void testParityCheck() { System.out.println("Test...