Why is True equal to -1

前端 未结 5 785
北海茫月
北海茫月 2020-12-03 11:25

I was wondering why True is equal to -1 and not 1. If I remember correctly (back in the days) in C, \"true\" would be equal to 1.

    Dim t, f As Integer

           


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 12:11

    I guess to goes back to assembly language where a conditional is translated to a compare cmp operation and the zero flag (ZF) is checked. For true expressions the ZF is not raised, and for false expressions it is. Early Intel processors are like that, but I cannot remember if the Zilog Z80 and the Motorola 8-bit processors had the same convention.

提交回复
热议问题