Binary bit analysis
Here's my situation, I need to be able to get this sort of response:
I have a 32 bit binary word, each bit corresponds to a certain alarm. So if a certain bit in the word is 1 then that alarm is flagged, however if several bits are 1 then all the corresponding alarms are flagged. Is there some way to use some sort of lookup table which will show which alarms have been triggered? |
I don't know how you want to display the results, but using =MID(A1,x,1)
where x is 1 to 32 will return the value of that bit. You can ite this in with an IF statement to give something like =IF(MID(A1,x,1)=1,"Alarm","Noalarm"). Note that this counts from the left, so changing x to 1 will return the MSB. -- Ian -- "MadManInABox" wrote in message ... Here's my situation, I need to be able to get this sort of response: I have a 32 bit binary word, each bit corresponds to a certain alarm. So if a certain bit in the word is 1 then that alarm is flagged, however if several bits are 1 then all the corresponding alarms are flagged. Is there some way to use some sort of lookup table which will show which alarms have been triggered? |
I'm afraid you didn't notice that Madman wrote 32 bits and not bytes!
Stefi €˛Ian€¯ ezt Ć*rta: I don't know how you want to display the results, but using =MID(A1,x,1) where x is 1 to 32 will return the value of that bit. You can ite this in with an IF statement to give something like =IF(MID(A1,x,1)=1,"Alarm","Noalarm"). Note that this counts from the left, so changing x to 1 will return the MSB. -- Ian -- "MadManInABox" wrote in message ... Here's my situation, I need to be able to get this sort of response: I have a 32 bit binary word, each bit corresponds to a certain alarm. So if a certain bit in the word is 1 then that alarm is flagged, however if several bits are 1 then all the corresponding alarms are flagged. Is there some way to use some sort of lookup table which will show which alarms have been triggered? |
Put your word (integer) into cell A1, select cells B1:B28 and enter
=MOD(INT($A$1/(2^(ROW()-1))),2) with CTRL+SHIFT+ENTER (as array formula). This will work for 28 bits (highest possible number: 268,435,455). HTH, Bernd |
I tried it, but it gave zero in all cells B1:B28 for any value in A1!
What's wrong? Stefi €˛Bernd Plumhoff€¯ ezt Ć*rta: Put your word (integer) into cell A1, select cells B1:B28 and enter =MOD(INT($A$1/(2^(ROW()-1))),2) with CTRL+SHIFT+ENTER (as array formula). This will work for 28 bits (highest possible number: 268,435,455). HTH, Bernd |
"Stefi" wrote in message
... I'm afraid you didn't notice that Madman wrote 32 bits and not bytes! Stefi Yes, I did. I am assuming this 32bit binary word is a string of 32 zeros & ones, each character representing 1 bit. If this is not the case, then perhaps MadManInABox could enlighten me. -- Ian -- |
All times are GMT +1. The time now is 10:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com