Not sure, but here is a different idea. By shifting two places, you are
multiplying by 4. You then are adding either a 2 (1,0), or a 3 (1,1). This
idea may work for larger numbers since the built-in HEX2BIN is rather
limited.
=A1*4+IF(MOD(ROUND(LOG(A1)/LOG(2),10),1)>=0.5,3,2)
...
First off, to match up with the OP's cell addresses, this should be
=F29*4+IF(MOD(ROUND(LOG(HEX2DEC(J29),2),10),1)>=0.5,3,2)
Now, I'll agree that the OP's formula
=HEX2BIN(F29,8)&LEFT(HEX2BIN(J29),2)
is equivalent to left shifting twice and adding 2 or 3 *MOST* of the time,
but not *ALL* of the time. If J29 were either 0 or 1, then HEX2BIN(J29)
returns either "0" or "1", respectively, and LEFT("0",2) = "0" while
LEFT("1",2) returns "1". So your formula doesn't match up with the OP's
formula when J29 is 0 or 1. Indeed, if J29 were zero, your formula returns
#NUM!. Even for positive J29, your formula can return incorrect results.
J29 == "17" (hex):
MOD(ROUND(LOG(HEX2DEC(J29),2),10),1) == 0.523561956 >= 0.5, so 3 or "11"
(bin),
but 23 (dec) == 10111 (bin), so the top bits are "10".
Similarly for 46-47, 91-95 and 182-191 on 0-255. You should have used
=F29*4+IF(MOD(ROUND(2^LOG(HEX2DEC(J29),2),10),1)>=0.5,3,2)
That said, it's almost certain the OP's formula is wrong. I'd bet the OP
meant
to use either
=HEX2BIN(F29,8)&LEFT(HEX2BIN(J29,2),2)
or
=HEX2BIN(F29,8)&LEFT(HEX2BIN(J29,8),2)
If not, and the OP's formula really is correct for the OP's needs, then the
OP's formula is optimal, and bit shifting unnecessary (and awkward).