Relizing there’s no such thing as a BOOL datatype, take the following:
std::cout << (1>2); //<<-- prints 0
Assuming this false comparison is a 0, what datatype deos the result of a comparison reduce to? Doing a quick google search doesn’t yield any results. My best guess it that it’s an unsigned char because it’s the smallest most basic datatype where 0 truly represented as 0x00. I don’t want to assume anything because I’m not sure what voodoo std::cout does to the value to make it a printable character.
The type of the result of all relational operators (
<,>,<=,>=) isbool:An object of type
boolhas the valuestrueorfalse.Under integral promotion, aboolcan be converted to anintwherefalsebecomes0andtruebecomes1:boolis an integral type, which the standard says are represented by use of a “pure binary numeration system”. The footnote that describes this representation is fairly unclear as to how it maps to the valuestrueandfalse, but you could assume that they are implying that the value representation for0would be all0bits: