Frage

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?

War es hilfreich?

Lösung

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 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top