Dart语言教程:按位运算符示例

2019-06-2214:56:49编程语言入门到精通Comments1,953 views字数 505阅读模式

示例显示如何在Dart中使用按位运算符 -文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/13738.html

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}"); 

   result = (a > b); 
   print("(a > b) => ${result}"); 
}

执行上面示例代码,得到以下结果:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/13738.html

(a & b) => 2
(a | b) => 3 
(a ^ b) => 1           
(~b) => -4             
(a < b) => true                             
(a > b) => false

原文出自【易百教程】,商业转载请联系作者获得授权,非商业转载请保留原文链接:https://www.yiibai.com/dart/dart_programming_operators.html#article-start文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/13738.html

文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/13738.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/ymba/13738.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定