當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Dart int.operator_bitwise_and用法及代碼示例

dart:core 庫中int.operator_bitwise_and 方法的用法介紹如下。

用法:

int operator &(
   int other   
)

位和運算符。

thisother 都視為足夠大的二進製分量整數,結果是一個數字,其中僅設置了在 thisother 中設置的位

如果兩個操作數都為負,則結果為負,否則結果為非負。

print((2 & 1).toRadixString(2)); // 0010 & 0001 -> 0000
print((3 & 1).toRadixString(2)); // 0011 & 0001 -> 0001
print((10 & 2).toRadixString(2)); // 1010 & 0010 -> 0010

相關用法


注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 operator & method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。