Numbers like 1 and 3 are odd, and 0 and 2 are even This can be computed with a simple Java method Modulo division With a modulo division, we determine if a number evenly divides into another In this way we tell if a number can be divided by 2 evenly—it is then even Warning For negative odd numbers, the remainder will be 1 not 1If the argument is NaN, this method will return NaN;Modulo arithmetic with negative operands is defined by the language designer, who might leave it to the language implementation, who might defer the definition to the CPU architecture I wasn't able to find a Java language definition
Data Types Declarations And Expressions In Java Variables
Math modulo negative numbers java