Chat on IRC |
Bool size
Posted by Webb21 [send private reply] at October 04, 2001, 07:07:07 PM
I've got this C++ programming book and in it , it has a little program you can make whick will tel you how many bytes are in bool or unsigned int, unsigned long int, etc. For the Windows variants it mentions bool as being 1 byte. I tried it on my system (non-windows) and it has shows bool being 4 bytes. My question is why would bool need to be 4 times as long as on a windows machine, like, what's the significance of this?
Posted by Psion [send private reply] at October 04, 2001, 07:53:13 PM
It's that long because someone decided it was most convenient to just make it a machine word ('int' in C).
Posted by gian [send private reply] at October 04, 2001, 09:34:45 PM
Bloatware!
Posted by taubz [send private reply] at October 05, 2001, 11:31:00 AM
No, fastware. It's fastest for the processor, I believe.
Posted by miken [send private reply] at October 05, 2001, 09:02:44 PM
Yes, a bool is an integer, 4 bytes because that is the fastest block of memory that a processor can process at once (32-bits). If a bool was only 1-bit, then it would incur minor performance penalties and be very inefficient. Further, memory in today's computers is quite abundant, meaning that a bool can basically be any length it wants to and not impede on your app's memory requirements.
Posted by Webb21 [send private reply] at October 06, 2001, 05:59:52 PM
Hey thanks a lot (in a serious non-sarcastic manner).
Posted by gian [send private reply] at October 06, 2001, 10:16:07 PM
Sorry, it's kindof strange... I never feel inclined to discriminate on the basis of age, gender, race or sexuality, but there's something about Macs... or maybe mac users, I don't really know which.
Posted by RedX [send private reply] at October 07, 2001, 12:52:36 PM
(not tested)I think if you optimize for size, instead of speed, the bool would be one byte, the smallest size any system can handle.
RedX
Posted by Webb21 [send private reply] at October 07, 2001, 11:18:11 PM
gian--relevancy?
Posted by gian [send private reply] at October 08, 2001, 09:59:46 PM
Nothing, just an observation about my own behaviour... ignore it if you will.
Register as a new user | ||||||||||||