Question

I need to calculate if a hexadecimal number is odd or even as a C function. Is there any function to do it directly?

If not, is there a function in C to directly convert from hexadecimal to binary?

Was it helpful?

Solution

for hexa to binary look at this page HTOI

or you can convert for hexa to decimal look at this function strtol

and then to binary using normal methods.

to find odd or not you can use

if(x & 1 == 1)
     //it's odd
else 
    // it's even 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top