Valhalla Legends Archive

Programming => General Programming => Topic started by: Ickypoopy on January 29, 2003, 06:41 PM

Title: BOOL
Post by: Ickypoopy on January 29, 2003, 06:41 PM
Here is a mind-numbingly pointless question...

If a BOOL must either be a 0 or 1, why is it 32 bits?

Title: Re: BOOL
Post by: Arta on January 30, 2003, 01:23 AM
afaik, it's 8 bits, not 32. A 32bit bool is a longbool, which can have different values, any of which is considered TRUE if it is nonzero. Come to think of it, i think the same applies to ordinary bools. Not sure :)
Title: Re: BOOL
Post by: Skywing on January 30, 2003, 03:41 AM
Quotelink=board=general_prog;num=1043901714;start=0#1 date=01/30/03 at 05:23:44]afaik, it's 8 bits, not 32. A 32bit bool is a longbool, which can have different values, any of which is considered TRUE if it is nonzero. Come to think of it, i think the same applies to ordinary bools. Not sure :)
Apparently Microsoft missed elementary-school math:
BOOL GetMessage(
  LPMSG lpMsg,         // message information
  HWND hWnd,           // handle to window
  UINT wMsgFilterMin,  // first message
  UINT wMsgFilterMax   // last message
);

If the function retrieves a message other than WM_QUIT, the return value is nonzero.

If the function retrieves the WM_QUIT message, the return value is zero.

If there is an error, the return value is -1.

The compiler generally converts values assigned to a bool to 0/1 with NOT and SBB (at least in Visual C++)...
Title: Re: BOOL
Post by: iago on January 30, 2003, 05:58 AM
The reason it isn't one bit is because most (all?) processors can't assign addresses to anything smaller than a byte, just like light can't travel in packets of enery less than whatever that certain little number is..
Title: Re: BOOL
Post by: Eibro on January 30, 2003, 03:50 PM
BOOL is a typedef of an int (4 bytes), at least on my system.
32 bit processors can work with 32 bit values faster than they can other sized data... I guess that's part of the reasoning behind the BOOL. You pay for speed with memory...

... Or so i've heard