std:bits リファレンス
@import 'std:bits' で取得するビット演算モジュール。Integer (任意精度・無限 2 の補数) の and / or / xor / not / shift_left / shift_right を提供する。
and
and(x, y)
and: { Int, Int | Int }
ビット AND (任意精度・無限 2 の補数)。
>>> bits.and(12, 10) 8
not
not(x)
not: { Int | Int }
ビット反転 (1 の補数)。not(x) == -x - 1。
>>> bits.not(0) -1
or
or(x, y)
or: { Int, Int | Int }
ビット OR (任意精度・無限 2 の補数)。
>>> bits.or(12, 10) 14
shift_left
shift_left(x, k)
shift_left: { Int, Int | Int }
左シフト (x * 2^k)。k は非負 (負値はエラー)。桁は無制限に伸びる。
>>> bits.shift_left(1, 4) 16
shift_right
shift_right(x, k)
shift_right: { Int, Int | Int }
算術右シフト (符号拡張 = floor(x / 2^k))。k は非負 (負値はエラー)。
>>> bits.shift_right(-16, 2) -4
xor
xor(x, y)
xor: { Int, Int | Int }
ビット XOR (任意精度・無限 2 の補数)。
>>> bits.xor(12, 10) 6