布尔

取值就是 true 或 false。

支持的运算符:

  1. && 逻辑与
  2. || 逻辑或
  3. ! 逻辑非
  4. == 等于
  5. != 不等于
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
pragma solidity ^0.8.0;

contract BoolOP {

function and_op(bool x,bool y) public returns (bool){
return x && y;
}

function or_op(bool x,bool y) public returns (bool){
return x||y;
}

function not(bool x) public returns (bool){
if (!x){
return false;
}
return true;
}

function equal(int x,int y) public returns (bool){
return x==y;
}

function not_equal(int x,int y) public returns (bool){
return x!=y;
}
}