Odd/even does not apply to floating point numbers.
Is 101.8 even? Is 92.3 odd? There is no way to tell.
If you are not interested in the fractional part, use casting and modulo
if (static_cast<int>(YourFloat) % 2 == 0) {
// even
}
Odd/even does not apply to floating point numbers.
Is 101.8 even? Is 92.3 odd? There is no way to tell.
If you are not interested in the fractional part, use casting and modulo
if (static_cast<int>(YourFloat) % 2 == 0) {
// even
}