- #1
ChrisVer
Gold Member
- 3,378
- 464
Hi guys, I have the following piece of code but I am not sure I understand if I get what it does correctly.
In fact I'm trying to understand the conditional. It says that if max is greater or equal to (1 <<9) it should do something. right?
1<<9 = (01) << 9 = (1000000000) = 29= 512 right?
(i bolded the binary numbers).
So the if statement will be executed if the value of max is larger or equal to 512?
Code:
static const unsigned int m_nBits = 6;
static const unsigned int m_nRanges = 4;
max = SOMENUMBER;
if( max >= (1 << (m_nBits + m_nRanges - 1) ) ){
doStuff()
}
1<<9 = (01) << 9 = (1000000000) = 29= 512 right?
(i bolded the binary numbers).
So the if statement will be executed if the value of max is larger or equal to 512?