Boolean true - positive 1 or negative 1?

前端 未结 11 1355
一生所求
一生所求 2020-12-31 11:05

I\'m designing a language, and trying to decide whether true should be 0x01 or 0xFF. Obviously, all non-zero values will be converted to true, but I\'m trying t

11条回答
  •  攒了一身酷
    2020-12-31 11:17

    IMO, if you want to stick with false=0x00, you should use 0x01. 0xFF is usually:

    • a sign that some operation overflowed

    or

    • an error marker

    And in both cases, it probably means false. Hence the *nix return value convention from executables, that true=0x00, and any non-zero value is false.

提交回复
热议问题