2 ms·
This doesn't make any sense even if the system isn't trashed. If 7 == true and anything other than 7 == false, then one bitflip will still change the meaning.
by rendaw 3y ago
This doesn't make any sense even if the system isn't trashed.
If 7 == true and anything other than 7 == false, then one bitflip will still change the meaning. If 7 == true and 0 == false, then you could have code that does `if (mybool == 7) { ... }` and later `if (mybool == 0) { ... }` and end up with a situation where code path invariants are broken (i.e. mybool is neither true nor false.
If you use `>= 7` to mean true and `< 7` to mean false, while a 0 false value won't randomly become true if one of 3 bits randomly flips, a `7` true value will become false if any of those bits flip. And if any of the other bits flip, 0 will become > 7.
- fabbari 3y agoIn C any value != 0 is considered true. Nothing special about 7, he could have used any other number, but 7 is a single character, so he used that.