I was studying about arithmetic types in C++ Prime by Stanley B. Lippman. When the author talks about integral types and the size of each one of them, like for example char is 8 bits, I noticed that it is not so clear the minimum size of a boolean. Considering type conversions, and the following code:
bool b = 42; // b is true
int i = b; // i had value 1
Can I say that booleans have the same minimum size of an integer (usually 16 bits), since if it is false it would be 0, that is an int, and 1 if it is true, another int? And if what I said is wrong, what is the minimum size of a boolean?
bool takes up a minimum 1 byte. Even though there are only two options of true or false, it can't be 1 bit because a bool needs to be addressable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With