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?

Était-ce utile?

La 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 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top