• Welcome to Valhalla Legends Archive.
 

BOOL

Started by Ickypoopy, January 29, 2003, 06:41 PM

Previous topic - Next topic

Ickypoopy

Here is a mind-numbingly pointless question...

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


Arta

#1
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 :)

Skywing

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++)...

iago

#3
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..
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Eibro

#4
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
Eibro of Yeti Lovers.