15,904,346 members
See more:
How do I check if a float number is even or odd

for example 2.2 is even and 4.3 is odd
Posted
Updated 4-Feb-17 15:52pm
ridoy 1-Jan-14 1:29am
certainly 2.2 is not an even nor 4.3 is an odd!

## Solution 2

"odd and even only applies to integers"

"Only integers are even or odd. We do not call fractions, irrational numbers, imaginary numbers, and so on either even or odd"

Any value that is not an even integer is odd.

2.2 is not even -- "An even number is an integer of the form n=2k, where k is an integer."

"An even number is an integer which is "evenly divisible" by two. This means that if the integer is divided by 2, it yields no remainder."

Convert to an integer (by multiplying by a power of ten) and try it, the answer may be wrong, but it depends on what you want to do with them.

Sergey Alexandrovich Kryukov 31-Dec-13 20:14pm
—SA
[no name] 31-Dec-13 20:33pm
You have given a good answer to a question that has no meaning.
ridoy 1-Jan-14 1:30am
+5

## Solution 1

You could do something like this:
C
`isEven = (num * 10) % 2 == 0;`

That only works if you only care about the first digit, depends on how many decimal places you want to go out to.

v3

## Solution 3

I agree with the others, only an integer can be "even" or "odd". As far as programming goes, I agree that an even number is [n MOD 2 = 0] or [n % 2 == 0]. But if I were trying to identify the furthest-right digit as "even" or "odd", I'd prolly use a substring to single out that digit, convert to integer, then check it as [digit Mod 2]. Maybe don't listen to me, though, I only just started my second semester programming...