== Why is this an issue?

include::../description.adoc[]

=== Noncompliant code example

[source,java]
----
public boolean isOdd(int x) {
  return x % 2 == 1;  // Noncompliant; if x is an odd negative, x % 2 == -1
}
----


=== Compliant solution

[source,java]
----
public boolean isOdd(int x) {
  return x % 2 != 0;
}
----


== Resources

* https://wiki.sei.cmu.edu/confluence/x/pDdGBQ[CERT, NUM51-J.] - Do not assume that the remainder operator always returns a nonnegative result for integral operands
* https://wiki.sei.cmu.edu/confluence/x/_NUxBQ[CERT, INT10-C] - Do not assume a positive remainder when using the % operator

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

include::../message.adoc[]

'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]

endif::env-github,rspecator-view[]
