示例显示如何在Dart中使用按位运算符 -
void main() {
var a = 2; // Bit presentation 10
var b = 3; // Bit presentation 11
var result = (a & b);
print("(a & b) => ${result}");
result = (a | b);
print("(a | b) => ${result}");
result = (a ^ b);
print("(a ^ b) => ${result}");
result = (~b);
print("(~b) => ${result}");
result = (a b);
print("(a > b) => ${result}");
}
Dart
执行上面示例代码,得到以下结果:
(a & b) => 2
(a | b) => 3
(a ^ b) => 1
(~b) => -4
(a true
(a > b) => false
原文出自【易百教程】,商业转载请联系作者获得授权,非商业转载请保留原文链接:https://www.yiibai.com/dart/dart_programming_operators.html#article-start