bool to int conversion
How portable is this conversion. Can I be sure that both assertions pass? int x = 4<5; assert(x==1); x = 4>5; assert(x==0); Don't ask why. I know that it is ugly. Thank you. Nawaz int x = 4<5; Completely portable. Standard conformant. bool to int conversion is implicit! §4.7/4 from the C++ Standard says (Integral Conversion ) If the source type is bool, the value false is converted to zero and the value true is converted to one . As for C, as far as I know there is no bool in C. (before 1999) So bool to int conversion is relevant in C++ only. In C, 4<5 evaluates to int value, in this case the