Re: Reverse a single bit in an integer
Posted: Thu Mar 18, 2010 8:33 pm
I already had that idea, but it does not work:
it does not flip bits 0 and 2, it toggles them each for each.
Code: Select all
n = 0
t = n ! %101
Debug Str(n) + ": " + RSet(Bin(n),3,"0") + " -> " + RSet(Bin(t),3,"0")
n = 2
t = n ! %101
Debug Str(n) + ": " + RSet(Bin(n),3,"0") + " -> " + RSet(Bin(t),3,"0")
n = 5
t = n ! %101
Debug Str(n) + ": " + RSet(Bin(n),3,"0") + " -> " + RSet(Bin(t),3,"0")
n = 7
t = n ! %101
Debug Str(n) + ": " + RSet(Bin(n),3,"0") + " -> " + RSet(Bin(t),3,"0")