为什么在C ++中true等于1? [英] why true equals 1 in C++ ?
本文介绍了为什么在C ++中true等于1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗯... False是00000000所以true必须是11111111 = -1十进制系统(255 unsigned)
在所有其他编程语言中我知道
(不是很多)true等于-1这更有意义......
怎么能不(FALSE)不是NOT(00000000)?
谢谢!!
Well...False is 00000000 so true must be 11111111=-1 in decimal system(255 unsigned)
In all of the other programming languages I know
(not many) true is equal to -1 which makes more sense...
how can NOT(FALSE) be something else than NOT(00000000) ?
Thank you !!
推荐答案
这里有一些见解:比较运算符值C ++at Stack Overflow [ ^ ]。
Some insight here: "comparison operator values C++" at Stack Overflow[^].
维基百科:
比较运算符('>',' =='等等)被定义为返回有符号整数(int)结果,零(对于假)或1(对于真)
The comparison operators ('>', '==', etc.) are defined to return a signed integer (int) result, either zero (for false) or 1 (for true)
这篇关于为什么在C ++中true等于1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文