How Can it ideally require 1 bit , if say for example 5 it requires 3 bits to store and why are non zero values true ?
Doubt In Boolean Section?
hey @AnshBajpai, a int value will take 32 bits or 64 bits depending upon system or compiler, i.e. 2 bytes or 4 bytes.
1 byte=8 bits.
Latest compiler consider int as 4 bytes too.
No, I mean that in the section where we are taught about boolean, the instructor mentions that only 1 bit Is required to store it but compiler provides a minimum allocation of 1 byte. So does boolean mean only 0 and 1 or even other non zero numbers. If it does then say 5 =101 which is 3 bits, I completely get the idea that it store in a bigger bucket. But then how only one bit is required to store it
hey @AnshBajpai, all non zero numbers are true, even negative number are also gives true.Only zero consitute to false.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.