## TasostGreat

i'm trying to figure out what is the fastest way to do an odd / even check on numbers i don't know whether there is a mathematical way of achieving this i've heard that the fastest would be checking the last bit in the binary array but i wonder what % does for example

``if(b%2!=0) then odd``

does % do divisions till it finds the result that's why i ask

## Salem 5,138

Getting the modulo result is a natural outcome of working out the division.

It's just that when you do x/2, the compiler just looks at a different part of the answer.

## ddanbe 2,720

How it is actually done I dunno.
But if I would write a routine that does it I would continuously subtract 2 from b until zero or until b<2 and return that value.

## TasostGreat

ok i have this code

``if (b | 0x1) odd(); else even();``

but it doesn't seem to work proper with some test files since it alway ends up at odd() what am i doing wrong b is alway an integer and positive what should i change

BTW i think that's the fastest way
thanx

## TasostGreat

is there any way of just checking the last bit in the binary array of a number

## Salem 5,138

That's what I just told you!
Did you even try it, or just dismiss it?

## ddanbe 2,720

I thought the question was how the modulo operator works, but it's about odd and even...

## TasostGreat

That's what I just told you!
Did you even try it, or just dismiss it?

i am sorry i thought i saw % and not & ok problem solved