| ▲ | RobotToaster a day ago |
| >and that it takes up one byte of memory You can make them smaller using bitfields in C. |
|
| ▲ | AlotOfReading a day ago | parent | next [-] |
| The object it's inside will still take up at least one byte. sizeof(struct {bool a:1;}) == sizeof(char);
|
| |
| ▲ | hinkley a day ago | parent [-] | | Amortization. If one Boolean must be a byte then 8 must be eight bytes. Which is not true. A boolean can be 1/8th of a byte which is a meaningful distinction. | | |
| ▲ | hinkley 20 hours ago | parent [-] | | 3^5 is 243 so one could also call an optional Boolean 1/5th of a byte, though 1/4 is so much simpler to read and write. | | |
|
|
|
| ▲ | russdill a day ago | parent | prev | next [-] |
| Um, no. Please show me how you can fit 255 possible states in something smaller than a byte by using bitfields. |
| |
| ▲ | RobotToaster a day ago | parent [-] | | I was quoting the first paragraph, where it says a single normal bool takes a byte. |
|
|
| ▲ | 5o1ecist 5 hours ago | parent | prev [-] |
| [dead] |