Which value is better to use? Boolean true or Integer 1?
The above topic made me do some experiments with bool
and in
Very few instruction set architectures define any sort of boolean operand type, although there are often instructions that trigger an action on non-zero values. To the CPU, usually, everything is one of the scalar types or a string of them.
A given compiler and a given ABI will need to choose specific sizes for int
and bool
and when, like in your case, these are different sizes they may generate slightly different code, and at some levels of optimization one may be slightly faster.
It's safer to choose a char
type for bool because someone might make a really large array of them.
Update: by "safer", I mean: for the compiler and library implementors. I'm not saying people need to reimplement the system type.