跳轉到內容

Futurebasic/語言/參考/bit

來自華夏公益教科書,自由的教科書

✔ 外觀 ✔ 標準 ✔ 控制檯

bitValue = bit( bitPos )

此函式返回一個整數,其二進位制表示形式在位置 bitPos 的位設定為“1”,所有其他位設定為“0”。位位置從右到左計數:bitPos 值為零對應於最右邊的(“最低有效”)位。bitPos 的最大允許值為 31,對應於長整數的值中最左邊的位。bit 與“按位運算子”(如 andor)結合使用很有用,用於設定和測試數量中特定位的的值。

如果 testValue& 中的位“n”已設定,則以下表達式計算為 _zTrue(-1)

( testValue& and bit( n ) ) <> 0

以下賦值將 testValue& 中的位“n”設定為 1

testValue& = ( testValue& or bit( n ) )

以下賦值將 testValue& 中的位“n”重置為 0

testValue& = ( testValue& and not bit( n ) )

如果 _bitPos 是一個符號常量名稱,那麼您可以使用 _bitPos%(注意“%”)作為 bit( _bitPos ) 的同義詞。

另請參閱

[編輯 | 編輯原始碼]

bin$; and; or; not; 附錄 C:資料型別和資料表示

語言參考

華夏公益教科書