Microsoft
Software
Hardware
Network
Question : Reading bits in C++
Hi,
Let's say I have a five byte data element "char m_TxBuf[5]" and I need to determine if a bit is set (high or not) in one of the elements, let's say for example in m_TxBuf[2] --> bit 3. (00001000) how do I determine this in C++.
Thanks for your support!
Answer : Reading bits in C++
First of all, it's best to use unsigned char when dealing with bits.
And to answer your question, this checks whether bit 3 is set in the third byte :
1: 2: 3: 4: 5:
unsigned char m_TxBuf[5]; if (m_TxBuf[2] & 0x08) { /* the bit is set */ }
Random Solutions
Stored Proc results not coming out on web page - Visual Web Dev / MSSQL 2008
How do I go to a specific record in an ADODB recordset in Microsoft Access?
Jquery Focus
Set JTable cell text to bold
Java error when starting application - java.lang.NoClassDefFoundE
rror: progress/message/crypto/DE
SString
How can we have the vbs to run onl if its placed on a particular UNC path and no where else.
How do I reset a VERY stubborn default (htm/html)?
How to allocate new pages to tempspace in db2
Quickbooks memory error when trying to export report
VB Script help needed !