It's actually a lot simpler than it may sound. It's just a bit trickier in TI-BASIC because TI-BASIC has no binary data types. To use your number as an example, if you break down 854 into binary, you get:
512 64 4
| | |
00000011 01010110
| | |
256 16 2
This says that 854 = 512+256+64+16+4+2. And there's your answer, right in there. Each bit tells you whether 2^([bit position from right]) is a binary component of the number. The trick is isolating the bit that you care about. I do this by rotating the number to points where TI-BASIC is able to mask off the bits I don't want. The functions I have to work with are iPart() and fPart(), which mask on either side of the decimal point, so I have to shift the bit I want immediately next to the decimal point to be able to use these effectively. First I do this by dividing by 2^([bit position]+1), which effectively shifts the binary number right [bit position]+1 places:
00000000 00000001.10101011 0
|
256
Then I can mask off all the bits on the left with fPart() (in this case, just the bit representing 512):
00000000 00000000.10101011 0
|
256
I then multiply by 2 to shift the number back one place to the left:
00000000 00000001.01010110
|
256
And finally, I can use iPart() to mask off all the bits on the right:
00000000 00000001.00000000
|
256
So I'm left with the bit representing 256 in the one's place of my number and all other digits gone, thus giving me the boolean value 1, which tells me that 256 is a binary component of 854.