| Real'sHowTo |
|
|
Custom Search
|
| Real'sHowTo |
|
|
Custom Search
|
For Other interesting modulus operations, see http://mindprod.com/jgloss/modulus.html
if (x % 2 == 0) {
// even
}
if (x % 2 != 0) {
// odd
}
... or binary AND operator...
if (( x & 1 ) == 0) {
// even
}
if (( x & 1 ) != 0) {
// odd
}
Written and compiled by Réal Gagnon ©1998-2013
[ home ]