布尔表达式

来源:互联网 发布:php测试工程师 编辑:程序博客网 时间:2024/04/30 19:46

运算关系从大到小:not>and>or
a and false==fase
a and true==a
a or false==a
a or true==true
当0和1对应false和true时:
and与乘法相似
or与加法相似
and和or操作符都符合分配率:
a or (b and c)==(a or b)and(a or c)
a and (b or c)==(a and b)or(a and c)
布尔代数符合德摩根定律:
not(a or b)==(not a)and(not b)
not(a and b)==(not a)or(not b)
对于序列类型来说,一个空序列被解释为假,而任何非空序列被指示为真。

bool(0)Falsebool(1)Truebool("hello")Truebool("")Falsebool([1,2,3])Truebool([])False
原创粉丝点击