Hex to Binary using a divide and conquer approach for the first and second digit

miki76

New member
Joined
Jul 17, 2012
Messages
3
Reaction score
0
Points
0
I am trying to find a formula that convert Hex to Binary. I have already found one but now I am required to use a divide and conquer approach for the first and second digit.
example:
Input Hex
B7
B= 1st digit 7= 2nd digit
Binary
10110111
someone suggest me to consider Right and Left functions to extract the digits from the input and “&” for concatenating strings… any formula suggestions?

Thanks
 
Seems like overkill considering HEX2BIN does this on it's own,

Code:
=HEX2BIN(A2,8)

but if you insist on using LEFT and RIGHT and "&", and a maximum of two characters, try:

Code:
=CHOOSE(LEN(A2),HEX2BIN(A2,4),HEX2BIN(LEFT(A2,1),4)&HEX2BIN(RIGHT(A2,1),4))

Cheers,
 
Last edited:
thank you so much... that's the formula i was trying to get... it works..
 
Can you please help me to reverse this formula to Bin2hex?
 
Again, you can do this with BIN2HEX like this:

Code:
=BIN2HEX(A2)

or using LEFT & RIGHT like this:

Code:
=IF(LEN(A2)=8,IF(BIN2HEX(LEFT(A2,4),1)="0",BIN2HEX(RIGHT(A2,4),1),BIN2HEX(LEFT(A2,4),1)&BIN2HEX(RIGHT(A2,4),1)),"Requires 8 binary digits")

Cheers,
 
Back
Top