Q
Hello
unsigned char a;
the a[0-3] represents a 4-bit binary,
a[4-6] represents another 3-bit binary.
I'd like to convert a[0-3] into a decimal.
For instance if {a[3] a[2] a[1] a[0}}= {0 1 0 1] the decimal should be
5
My program is like
if((a && 0x00)==1) return 0;
else if (a&& 0x01)==1) return 1;
.....
Is there any simpler way for it?
Thanks a lot!
unsigned char a;
the a[0-3] represents a 4-bit binary,
a[4-6] represents another 3-bit binary.
I'd like to convert a[0-3] into a decimal.
For instance if {a[3] a[2] a[1] a[0}}= {0 1 0 1] the decimal should be
5
My program is like
if((a && 0x00)==1) return 0;
else if (a&& 0x01)==1) return 1;
.....
Is there any simpler way for it?
Thanks a lot!