RichardMartens Posted March 12, 2018 Share Posted March 12, 2018 (edited) I have a binary number, how do I check to see if an individual bit in the number is on or off. And btw, I have the binary numbers in a data array. for example: I have %11010000 I want to see if the left most bit is a one or a zero, then I want to check if the next bit is also a one or a zero, and so on. So the first two checks would come back as 1s, and the third would tell me it's a zero. EDIT ***** I may have figured it out, I just have to assine each binary number to a variable the I can check it, for example: ; Data table 02 data _Grid_Line01 %11010000, %00001101, %00000011 end a = _Grid_Line01[0] if a{0}=0 then goto __No Edited March 12, 2018 by RichardMartens Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted March 12, 2018 Share Posted March 12, 2018 What is supposed to happen when the bits are off or on? Are all bits supposed to be checked because something different happens or does the same thing happen when any bit is on? For example, this does something if any bit is on: temp6 = _Grid_Line01[0] temp5 = 0 __Bit_Check_Loop if temp6{temp5} then goto __Do_Something temp5 = temp5 + 1 : if temp5 < 8 then goto __Bit_Check_Loop This does something different for each bit if it is on: temp6 = _Grid_Line01[0] if temp6{0} then _Something0 = _Blah_Blah if temp6{1} then _Something1 = _Blah_Blah if temp6{2} then _Something2 = _Blah_Blah if temp6{3} then _Something3 = _Blah_Blah if temp6{4} then _Something4 = _Blah_Blah if temp6{5} then _Something5 = _Blah_Blah if temp6{6} then _Something6 = _Blah_Blah if temp6{7} then _Something7 = _Blah_Blah If you want something to happen for each bit, you can't jump somewhere else (unless it's a gosub) because the other bits won't be checked. Also remember to check out the Did You Know? box here because you can't use an equal sign with bits: randomterrain.com/atari-2600-memories-batari-basic-commands.html#bit Quote Link to comment Share on other sites More sharing options...
RichardMartens Posted March 13, 2018 Author Share Posted March 13, 2018 Im just starting out, and have a bad memory, so i sometimes forget formatting and miner rules. But thanks anyways. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.