ok i couldn't wait till tomorrow, and found the solution (OwYeah =D ) (it is different from yours, but works, is fast and small, everything i needed)

assuming E is the number of the bit i want, following this logic: 1_{6}0_{5}0_{4}1_{3}0_{2}0_{1}0_{0} so E=6 results 1…

assuming D is the Decimal number (not zero, not imaginary,not negative, whole)

then the GETBIT function goes as follows

```
:D→B
:0
:For(A,1+int(log(B)/log(2)),0,-1),E //1+int(logB/log2) gives the number of bits there are. this will loop through our Bits,
stopping at the E'th bit
:0
:If B≥A^2 :Then // if this is true our bit is 1
:B-(2^A→B // subtracts the power of 2 of the bit we are currently at, if it was 1, else does nothing
:1
:End:End
```

now, the value in Ans contains the bit we wanted

the SETBIT1 function (makes any Bit a 1), follows conventions mentioned above

```
:prgrmGETBIT //execute previous function
:D+(2^E)not(Ans //if Ans(the bit we checked) was zero, we add the appropriate power of 2 to B,
making that bit 1, else we leave D alone
```

Ans now contains the new Decimal number, with 1 bit of choice set to 1

if the above is clear, next one comes as no surprise

SETBIT0

```
:prgrmGETBIT
:D-Ans(2^E //if Ans(the bit we checked) was 1, we substract the appropriate power of 2 from B,
making that bit 0, else we leave D alone
```

now, the final routine, changing a 1 to 0 and a 0 to 1, just combines the previous 2

CHANGEBIT

```
:prgrmGETBIT
:D+2^E(1-2Ans
```

i optimized this code as much as possible, and it is pretty fast and pretty small for the compression it provides

notice that D can not be bigger than 2^46 because of rounding the calc will do, so a maximum of 46 bits can be stored in 1 Variable.

if this idea is as "clever" as you mentioned maybe it can have its own routine page? it doesn't have that many uses though, but I'd like to give something back to the community after all the info leeching i did last 2 years