Forum Discussion
anupambit1797
Jun 13, 2023Iron Contributor
Reverse_Bits
Dear Experts, Could you please share a Formula on how can I reverse the bits from LSB to MSB in Column "C", with results in Column "D" Thanks in Advance, Br, Anupam
- Jun 14, 2023
anupambit1797 so i had some fun with this.
a) here is an alternative to create the dec2bin for large numbers (not claiming it to be more efficient just an alternative). It uses a recursive LAMBDA function:
=RIGHT(REPT("0",32)&d2b(A2),32) d2b = LAMBDA(in, IF(in>2,d2b(QUOTIENT(in,2)),in-1) & MOD(in,2))Here is the reverse bits:
=LET(in,D2,CONCAT(MID(in,SEQUENCE(LEN(in),,LEN(in),-1),1)))it could be more simple if you assume only for 32 bits:
=CONCAT(MID(D2,SEQUENCE(32,,32,-1),1))
mtarler
Jun 14, 2023Silver Contributor
anupambit1797 so i had some fun with this.
a) here is an alternative to create the dec2bin for large numbers (not claiming it to be more efficient just an alternative). It uses a recursive LAMBDA function:
=RIGHT(REPT("0",32)&d2b(A2),32)
d2b = LAMBDA(in, IF(in>2,d2b(QUOTIENT(in,2)),in-1) & MOD(in,2))Here is the reverse bits:
=LET(in,D2,CONCAT(MID(in,SEQUENCE(LEN(in),,LEN(in),-1),1)))it could be more simple if you assume only for 32 bits:
=CONCAT(MID(D2,SEQUENCE(32,,32,-1),1))