I think this code:

```
:D→B
:0 // this will make sure that if I is greater than the highest index, 0 will be returned
:If D:Then //log(0) would give domain error, and 0d=0b.
:For(A,1+int(log(D)/log(2)),I,-1) //A will run through the indexes, from high to low
stopping at I(the one we needed). log(D)/log(2) = base 2 log of D
:0
:If 2^A≥B: Then
:B-2^A→B
:1
End:End:End
```

Could be shortened to this for most scenarios:

`int(2fPart(.5D/2^I`

For example, to test bit 2 of the value 18:

.5*18/2^2

9/4

2.25

int(2fPart(2.25

int(2*.25

0

and 18=10010

_{b}, which fits. Testing bit 4:

.5*18/2^4

9/16=.5625

int(2fPart(.5625

int(1.125

1

I am not sure how much accuracy it will retain for very large numbers, though, so you will probably need to do a check if I>32 or something.

**EDIT:** I often use this short routine for testing bits when I don't want to actually convert a number to binary. For example, with the routine I posted for raising A^K mod M, I used this to test the bits in K.

47%? Take a look and try to imagine how cool 100% will be. This has won zContest 2011 and made news on TICalc. This compromise between Assembly and BASIC parses like BASIC and is fast like assembly. Grammer 2