+ 3
Size of booleans
According to the sizeof(); table in the lesson, a boolean allocates 1 byte but since a boolean can only hold 0 or 1, wouldnt it htake up a bit?
4 ответов
+ 2
In general, no data type will be a single bit because it is inconvenient to allocate and deal with less than a byte. If you are storing a lot of booleans, than you could pack up to 8 of them into a byte using something called bitfields, or even use bitwise operations to store them in integers, but you can't simply use a bit of storage by itself.
+ 1
CPUs consider a byte as a smallest addressable unit.
+ 1
Since 1 byte consists of 8 bits, 0 & 1can be written in terms of bytes like this 00000000 and 00000001 respectively.
0
the "1" is for us but for the computer it is "00110001"