<< bitor bitwise bitxor >>

Scilab help >> Elementary Functions > bitwise > bitset

bitset

指定した位置のビットを設定

呼び出し手順

y = bitset(x,pos)
y = bitset(x,pos,v)

パラメータ

x :

m行n列の行列(double)またはm1 x m2 x ... x mm ハイパー行列(double) または符合なし整数(uint8, uint16 または uint32)の m行n列行列.値は正の整数値である必要があります.

pos :

m行n列の行列(double)またはm1 x m2 x ... x mm ハイパー行列(double) または符合なし整数(uint8, uint16 または uint32)のm行n列行列. 入力 pos は 1,2,...,bitmaxの範囲とする 必要があります.ただし, bitmax は x の最大ビット数です. 値は正の整数値である必要があります.

v :

m行n列の行列(double)またはm1 x m2 x ... x mm ハイパー行列(double) または符合なし整数(uint8, uint16 または uint32)の m行n列行列.値は正の整数値である必要があります.

y :

m行n列の行列(double)またはm1 x m2 x ... x mm ハイパー行列(double) または符合なし整数.

説明

指定した位置のビットを設定します.

例

// 9 is (01001)_2
// We set the 5th bit to 1, which gives
//      (11001)_2 producing 25
bitset(uint8(9), 5)
expected = 25

// Set the 5th bit of 25 to 0.
bitset(uint8(25), 5, 0)
expected = 9

// The input can be a positive double
bitset(25, 5, 0)
expected = 9

作者

<< bitor bitwise bitxor >>