diff --git a/builtin/bigint.mbt b/builtin/bigint.mbt index 38bbac7d9..b1f5b52d8 100644 --- a/builtin/bigint.mbt +++ b/builtin/bigint.mbt @@ -216,8 +216,8 @@ fn karatsuba_mul(self : BigInt, other : BigInt) -> BigInt { let p1 = xh * yh let p2 = xl * yl let p3 = (xh + xl) * (yh + yl) - p1.shl(radix_bit_len * 2 * half) + - (p3 - p1 - p2).shl(radix_bit_len * half) + + (p1 << (radix_bit_len * 2 * half)) + + ((p3 - p1 - p2) << (radix_bit_len * half)) + p2 } @@ -328,8 +328,8 @@ fn grade_school_div(self : BigInt, other : BigInt) -> (BigInt, BigInt) { (64 - divisor.limbs[divisor.len - 1].to_uint64().to_int64().clz()), ) let a_len = dividend.len - let dividend = dividend.shl(lshift) - let divisor = divisor.shl(lshift) + let dividend = dividend << lshift + let divisor = divisor << lshift let b_len = divisor.len let b = FixedArray::make(b_len, 0UL) for i = 0; i < b_len; i = i + 1 { @@ -370,24 +370,24 @@ fn grade_school_div(self : BigInt, other : BigInt) -> (BigInt, BigInt) { borrow += a[i + j].to_int64() borrow -= carry.land(radix_mask).to_int64() a[i + j] = borrow.land(radix_mask.to_int64()).to_uint64() - borrow = borrow.shr(radix_bit_len) + borrow = borrow >> radix_bit_len carry = carry.lsr(radix_bit_len) } borrow = borrow + a[i + b_len].to_int64() borrow -= carry.to_int64() a[i + b_len] = borrow.land(radix_mask.to_int64()).to_uint64() - borrow = borrow.shr(radix_bit_len) + borrow = borrow >> radix_bit_len if borrow < 0L { carry = 0UL for j = 0; j < b_len; j = j + 1 { carry += a[i + j] carry += b[j] - a[i + j] = carry.land(radix_mask) - carry = carry.shr(radix_bit_len) + a[i + j] = carry & radix_mask + carry = carry >> radix_bit_len } carry += a[i + b_len] - a[i + b_len] = carry.land(radix_mask) - carry = carry.shr(radix_bit_len) + a[i + b_len] = carry & radix_mask + carry = carry >> radix_bit_len borrow += carry.to_int64() qh -= 1 } @@ -410,7 +410,7 @@ fn grade_school_div(self : BigInt, other : BigInt) -> (BigInt, BigInt) { modulo[j] = a[j].to_uint() } let modulo = { limbs: modulo, sign: Positive, len: i } - ({ limbs: q, sign: Positive, len }, modulo.shr(lshift)) + ({ limbs: q, sign: Positive, len }, modulo >> lshift) } // Bitwise Operations @@ -433,7 +433,7 @@ pub fn lsl(self : BigInt, n : Int) -> BigInt { if r != 0 { let mut carry = 0UL for i = 0; i < self.len; i = i + 1 { - carry = carry.lor(a[i].to_uint64().lsl(r)) + carry = carry | a[i].to_uint64().lsl(r) new_limbs[i + lz] = (carry % radix).to_uint() carry = carry.lsr(radix_bit_len) } @@ -456,13 +456,6 @@ pub fn lsl(self : BigInt, n : Int) -> BigInt { /// The sign of the result is the same as the sign of the input. /// Only the absolute value is shifted. pub fn op_shl(self : BigInt, n : Int) -> BigInt { - self.shl(n) -} - -/// Left shift a bigint -/// The sign of the result is the same as the sign of the input. -/// Only the absolute value is shifted. -pub fn shl(self : BigInt, n : Int) -> BigInt { if n < 0 { abort("negative shift count") } @@ -478,7 +471,7 @@ pub fn shl(self : BigInt, n : Int) -> BigInt { if r != 0 { let mut carry = 0UL for i = 0; i < self.len; i = i + 1 { - carry = carry.lor(a[i].to_uint64().lsl(r)) + carry = carry | a[i].to_uint64().lsl(r) new_limbs[i + lz] = (carry % radix).to_uint() carry = carry.lsr(radix_bit_len) } @@ -495,17 +488,17 @@ pub fn shl(self : BigInt, n : Int) -> BigInt { } } -/// Right shift a bigint +/// Left shift a bigint /// The sign of the result is the same as the sign of the input. /// Only the absolute value is shifted. -pub fn op_shr(self : BigInt, n : Int) -> BigInt { - self.shr(n) +pub fn shl(self : BigInt, n : Int) -> BigInt { + self << n } /// Right shift a bigint /// The sign of the result is the same as the sign of the input. /// Only the absolute value is shifted. -pub fn shr(self : BigInt, n : Int) -> BigInt { +pub fn op_shr(self : BigInt, n : Int) -> BigInt { if n < 0 { abort("negative shift count") } @@ -543,6 +536,13 @@ pub fn shr(self : BigInt, n : Int) -> BigInt { } } +/// Right shift a bigint +/// The sign of the result is the same as the sign of the input. +/// Only the absolute value is shifted. +pub fn shr(self : BigInt, n : Int) -> BigInt { + self >> n +} + pub fn asr(self : BigInt, n : Int) -> BigInt { self >> n } @@ -614,7 +614,7 @@ pub fn to_string(self : BigInt) -> String { for i = self.len - 1; i >= 0; i = i - 1 { let mut x = self.limbs[i].to_uint64().to_int64() for j = 0; j < v_idx; j = j + 1 { - let y = v[j].lsl(radix_bit_len).lor(x) + let y = v[j].lsl(radix_bit_len) | x x = y / decimal_mask v[j] = y % decimal_mask } @@ -829,18 +829,16 @@ pub fn BigInt::from_octets(input : Bytes, ~signum : Int = 1) -> BigInt { let limbs = FixedArray::make(limbs_len, 0U) // head at most significant limb for i = 0; i < mod / 8; i = i + 1 { - limbs[limbs_len - 1] = limbs[limbs_len - 1] - .lsl(8) - .lor(input[i].to_int().reinterpret_as_uint()) + limbs[limbs_len - 1] = limbs[limbs_len - 1].lsl(8) | + input[i].to_int().reinterpret_as_uint() } let byte_per_limb = radix_bit_len / 8 // tail for i = 0; i < div; i = i + 1 { for j = 0; j < byte_per_limb; j = j + 1 { let bytes_idx = len - byte_per_limb - i * byte_per_limb + j - limbs[i] = limbs[i] - .lsl(8) - .lor(input[bytes_idx].to_int().reinterpret_as_uint()) + limbs[i] = limbs[i].lsl(8) | + input[bytes_idx].to_int().reinterpret_as_uint() } } if limbs[limbs_len - 1] == 0 { @@ -879,7 +877,7 @@ pub fn BigInt::to_octets(self : BigInt, ~length? : Int) -> Bytes { let len = max(length, len) let result = Bytes::new(len) for i = 0; i < len && i / 4 < self.len; i = i + 1 { - result[len - 1 - i] = (self.limbs[i / 4].shr(i % 4 * 8) & 0xffU) + result[len - 1 - i] = ((self.limbs[i / 4] >> (i % 4 * 8)) & 0xffU) .reinterpret_as_int() .to_byte() } diff --git a/builtin/bigint_test.mbt b/builtin/bigint_test.mbt index a436de1b1..0fbfe53c8 100644 --- a/builtin/bigint_test.mbt +++ b/builtin/bigint_test.mbt @@ -377,21 +377,18 @@ test "lsl" { test "shr" { let a = BigInt::from_int64(1234567890123456789L) - let b = a.shr(1) + let b = a >> 1 inspect!(b.to_string(), content="617283945061728394") - let c = a.shr(64) + let c = a >> 64 inspect!(c.to_string(), content="0") let a = BigInt::from_int64(-1234567890123456789L) - let b = a.shr(1) + let b = a >> 1 inspect!(b.to_string(), content="-617283945061728395") - let c = a.shr(64) + let c = a >> 64 inspect!(c.to_string(), content="-1") - assert_eq!( - BigInt::from_int64(0b1111_1111L).shr(4), - BigInt::from_int64(0b1111L), - ) - assert_eq!(BigInt::from_int64(0b1111_1111L).shr(24), BigInt::from_int64(0)) - assert_eq!(BigInt::from_int64(0b1111_1111L).shr(44), BigInt::from_int64(0)) + assert_eq!(BigInt::from_int64(0b1111_1111L) >> 4, BigInt::from_int64(0b1111L)) + assert_eq!(BigInt::from_int64(0b1111_1111L) >> 24, BigInt::from_int64(0)) + assert_eq!(BigInt::from_int64(0b1111_1111L) >> 44, BigInt::from_int64(0)) } test "decimal_string" { @@ -567,12 +564,12 @@ test "panic op_mod coverage for modulo by zero" { test "panic shl coverage for negative shift" { let a = BigInt::from_int(123456789) - a.shl(-1) |> ignore + a << -1 |> ignore } test "panic lsr coverage for negative shift" { let a = BigInt::from_int(123456789) - a.shl(-1) |> ignore + a << -1 |> ignore } test "panic from_string coverage for empty string" { diff --git a/builtin/bigint_wbtest.mbt b/builtin/bigint_wbtest.mbt index bed4d46a2..c8fdd5acf 100644 --- a/builtin/bigint_wbtest.mbt +++ b/builtin/bigint_wbtest.mbt @@ -397,14 +397,14 @@ test "shl" { test "shr" { let a = BigInt::from_int64(1234567890123456789L) - let b = a.shr(1) + let b = a >> 1 check_len!(b) inspect!(b.to_string(), content="617283945061728394") - let c = a.shr(64) + let c = a >> 64 check_len!(c) inspect!(c.to_string(), content="0") let a = BigInt::from_int64((radix * radix / 2).to_int64()) - let b = a.shr(radix_bit_len * 2) + let b = a >> (radix_bit_len * 2) check_len!(b) inspect!(b.to_string(), content="0") } @@ -813,12 +813,12 @@ test "panic op_mod coverage for modulo by zero" { test "panic shl coverage for negative shift" { let a = BigInt::from_int(123456789) - a.shl(-1) |> ignore + a << -1 |> ignore } test "panic shr coverage for negative shift" { let a = BigInt::from_int(123456789) - a.shr(-1) |> ignore + a >> -1 |> ignore } test "panic from_string coverage for empty string" { diff --git a/builtin/byte_test.mbt b/builtin/byte_test.mbt index a70be5abd..1b2a6ff7b 100644 --- a/builtin/byte_test.mbt +++ b/builtin/byte_test.mbt @@ -57,19 +57,19 @@ test "byte_lsr" { } test "byte_lxor" { - assert_eq!(b'\xFF'.lxor(b'\xFF'), b'\x00') - assert_eq!(b'\xFF'.lxor(b'\x0F'), b'\xF0') - assert_eq!(b'\x0F'.lxor(b'\xFF'), b'\xF0') + assert_eq!(b'\xFF' ^ b'\xFF', b'\x00') + assert_eq!(b'\xFF' ^ b'\x0F', b'\xF0') + assert_eq!(b'\x0F' ^ b'\xFF', b'\xF0') } test "byte_lor" { - assert_eq!(b'\xFF'.lor(b'\xFF'), b'\xFF') - assert_eq!(b'\xFF'.lor(b'\x0F'), b'\xFF') - assert_eq!(b'\x0F'.lor(b'\xFF'), b'\xFF') + assert_eq!(b'\xFF' | b'\xFF', b'\xFF') + assert_eq!(b'\xFF' | b'\x0F', b'\xFF') + assert_eq!(b'\x0F' | b'\xFF', b'\xFF') } test "byte_land" { - assert_eq!(b'\xFF'.land(b'\xFF'), b'\xFF') - assert_eq!(b'\xFF'.land(b'\x0F'), b'\x0F') - assert_eq!(b'\x0F'.land(b'\xFF'), b'\x0F') + assert_eq!(b'\xFF' & b'\xFF', b'\xFF') + assert_eq!(b'\xFF' & b'\x0F', b'\x0F') + assert_eq!(b'\x0F' & b'\xFF', b'\x0F') } diff --git a/builtin/bytes.mbt b/builtin/bytes.mbt index eca87249e..dcdb0025b 100644 --- a/builtin/bytes.mbt +++ b/builtin/bytes.mbt @@ -115,8 +115,8 @@ pub fn set_utf16_char(self : Bytes, offset : Int, value : Char) -> Int { 2 } else if code < 0x110000 { let hi = code - 0x10000 - let lo = hi.lsr(10).lor(0xD800) - let hi = hi.land(0x3FF).lor(0xDC00) + let lo = hi.lsr(10) | 0xD800 + let hi = (hi & 0x3FF) | 0xDC00 self[offset] = lo.land(0xFF).to_byte() self[offset + 1] = lo.lsr(8).to_byte() self[offset + 2] = hi.land(0xFF).to_byte() diff --git a/builtin/hasher.mbt b/builtin/hasher.mbt index 65bd92728..7a59e6583 100644 --- a/builtin/hasher.mbt +++ b/builtin/hasher.mbt @@ -118,17 +118,14 @@ fn consume1(self : Hasher, input : Byte) -> Unit { } fn rotl(x : Int, r : Int) -> Int { - x.lsl(r).lor(x.lsr(32 - r)) + x.lsl(r) | x.lsr(32 - r) } fn endian32(input : Bytes, cur : Int) -> Int { - input[cur + 0] - .to_int() - .lor( - input[cur + 1] - .to_int() - .lsl(8) - .lor(input[cur + 2].to_int().lsl(16).lor(input[cur + 3].to_int().lsl(24))), + input[cur + 0].to_int() | + ( + input[cur + 1].to_int().lsl(8) | + (input[cur + 2].to_int().lsl(16) | input[cur + 3].to_int().lsl(24)) ) } @@ -148,13 +145,13 @@ pub impl Hash for Bytes with hash_combine(self, hasher) { // https://github.com/skeeto/hash-prospector pub impl Hash for Int with hash(self) { - let mut x = self.lxor(self.lsr(17)) + let mut x = self ^ self.lsr(17) x = x * 0xed5ad4bb - x = x.lxor(x.lsr(11)) + x = x ^ x.lsr(11) x = x * 0xac4c1b51 - x = x.lxor(x.lsr(15)) + x = x ^ x.lsr(15) x = x * 0x31848bab - x = x.lxor(x.lsr(14)) + x = x ^ x.lsr(14) x } diff --git a/builtin/int64.js.mbt b/builtin/int64.js.mbt index 7d74bd073..3f62f0998 100644 --- a/builtin/int64.js.mbt +++ b/builtin/int64.js.mbt @@ -36,7 +36,7 @@ fn MyInt64::add_hi_lo(self : MyInt64, bhi : Int, blo : Int) -> MyInt64 { let s = lo.asr(31) let as_ = alo.asr(31) let bs = blo.asr(31) - let c = as_.land(bs).lor(s.lnot().land(as_.lxor(bs))).land(1) + let c = ((as_ & bs) | (s.lnot() & (as_ ^ bs))) & 1 let hi = ahi + bhi + c { hi, lo } } @@ -57,34 +57,34 @@ fn MyInt64::op_mul(self : MyInt64, other : MyInt64) -> MyInt64 { let { hi: ahi, lo: alo } = self let { hi: bhi, lo: blo } = other let a48 = ahi.lsr(16) - let a32 = ahi.land(0xffff) + let a32 = ahi & 0xffff let a16 = alo.lsr(16) - let a00 = alo.land(0xffff) + let a00 = alo & 0xffff let b48 = bhi.lsr(16) - let b32 = bhi.land(0xffff) + let b32 = bhi & 0xffff let b16 = blo.lsr(16) - let b00 = blo.land(0xffff) + let b00 = blo & 0xffff let c00 = a00 * b00 let c16 = c00.lsr(16) - let c00 = c00.land(0xffff) + let c00 = c00 & 0xffff let c16 = c16 + a16 * b00 let c32 = c16.lsr(16) - let c16 = c16.land(0xffff) + let c16 = c16 & 0xffff let c16 = c16 + a00 * b16 let c32 = c32 + c16.lsr(16) - let c16 = c16.land(0xffff) + let c16 = c16 & 0xffff let c32 = c32 + a32 * b00 let c48 = c32.lsr(16) - let c32 = c32.land(0xffff) + let c32 = c32 & 0xffff let c32 = c32 + a16 * b16 let c48 = c48 + c32.lsr(16) - let c32 = c32.land(0xffff) + let c32 = c32 & 0xffff let c32 = c32 + a00 * b32 let c48 = c48 + c32.lsr(16) - let c32 = c32.land(0xffff) + let c32 = c32 & 0xffff let c48 = c48 + a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48 - let c48 = c48.land(0xffff) - { hi: c48.lsl(16).lor(c32), lo: c16.lsl(16).lor(c00) } + let c48 = c48 & 0xffff + { hi: c48.lsl(16) | c32, lo: c16.lsl(16) | c00 } } struct Int64WasmHelper { @@ -142,54 +142,45 @@ fn MyInt64::lnot(self : MyInt64) -> MyInt64 { } fn MyInt64::land(self : MyInt64, other : MyInt64) -> MyInt64 { - { hi: self.hi.land(other.hi), lo: self.lo.land(other.lo) } + { hi: self.hi & other.hi, lo: self.lo & other.lo } } fn MyInt64::lor(self : MyInt64, other : MyInt64) -> MyInt64 { - { hi: self.hi.lor(other.hi), lo: self.lo.lor(other.lo) } + { hi: self.hi | other.hi, lo: self.lo | other.lo } } fn MyInt64::lxor(self : MyInt64, other : MyInt64) -> MyInt64 { - { hi: self.hi.lxor(other.hi), lo: self.lo.lxor(other.lo) } + { hi: self.hi ^ other.hi, lo: self.lo ^ other.lo } } fn MyInt64::lsl(self : MyInt64, shift : Int) -> MyInt64 { - let shift = shift.land(63) + let shift = shift & 63 if shift == 0 { self } else if shift < 32 { - { - hi: self.hi.lsl(shift).lor(self.lo.lsr(32 - shift)), - lo: self.lo.lsl(shift), - } + { hi: self.hi.lsl(shift) | self.lo.lsr(32 - shift), lo: self.lo.lsl(shift) } } else { { hi: self.lo.lsl(shift - 32), lo: 0 } } } fn MyInt64::lsr(self : MyInt64, shift : Int) -> MyInt64 { - let shift = shift.land(63) + let shift = shift & 63 if shift == 0 { self } else if shift < 32 { - { - hi: self.hi.lsr(shift), - lo: self.lo.lsr(shift).lor(self.hi.lsl(32 - shift)), - } + { hi: self.hi.lsr(shift), lo: self.lo.lsr(shift) | self.hi.lsl(32 - shift) } } else { { hi: 0, lo: self.hi.lsr(shift - 32) } } } fn MyInt64::asr(self : MyInt64, shift : Int) -> MyInt64 { - let shift = shift.land(63) + let shift = shift & 63 if shift == 0 { self } else if shift < 32 { - { - hi: self.hi.asr(shift), - lo: self.lo.lsr(shift).lor(self.hi.lsl(32 - shift)), - } + { hi: self.hi.asr(shift), lo: self.lo.lsr(shift) | self.hi.lsl(32 - shift) } } else { { hi: self.hi.asr(31), lo: self.hi.asr(shift - 32) } } @@ -265,7 +256,7 @@ extern "js" fn MyInt64::compare_u(self : MyInt64, other : MyInt64) -> Int = #|} fn MyInt64::from_int(value : Int) -> MyInt64 { - { hi: value.asr(31).land(-1), lo: value.lor(0) } + { hi: value.asr(31) & -1, lo: value | 0 } } fn MyInt64::to_int(self : MyInt64) -> Int { diff --git a/builtin/int64_test.mbt b/builtin/int64_test.mbt index 06955a182..d4aaa6701 100644 --- a/builtin/int64_test.mbt +++ b/builtin/int64_test.mbt @@ -2974,995 +2974,983 @@ test "9223372036854775807 %u 9223372036854775807 = 0" { } test "0 | 0 = 0" { - assert_eq!(0L.lor(0L), 0L) + assert_eq!(0L | 0L, 0L) } test "0 | -1 = -1" { - assert_eq!(0L.lor(-1L), -1L) + assert_eq!(0L | -1L, -1L) } test "0 | 1 = 1" { - assert_eq!(0L.lor(1L), 1L) + assert_eq!(0L | 1L, 1L) } test "0 | 2147483647 = 2147483647" { - assert_eq!(0L.lor(2147483647L), 2147483647L) + assert_eq!(0L | 2147483647L, 2147483647L) } test "0 | -2147483648 = -2147483648" { - assert_eq!(0L.lor(-2147483648L), -2147483648L) + assert_eq!(0L | -2147483648L, -2147483648L) } test "0 | 2147483648 = 2147483648" { - assert_eq!(0L.lor(2147483648L), 2147483648L) + assert_eq!(0L | 2147483648L, 2147483648L) } test "0 | -2147483649 = -2147483649" { - assert_eq!(0L.lor(-2147483649L), -2147483649L) + assert_eq!(0L | -2147483649L, -2147483649L) } test "0 | 9223372036854775807 = 9223372036854775807" { - assert_eq!(0L.lor(9223372036854775807L), 9223372036854775807L) + assert_eq!(0L | 9223372036854775807L, 9223372036854775807L) } test "0 | -9223372036854775808 = -9223372036854775808" { - assert_eq!(0L.lor(-9223372036854775808L), -9223372036854775808L) + assert_eq!(0L | -9223372036854775808L, -9223372036854775808L) } test "0 | -9223372036854775808 = -9223372036854775808" { - assert_eq!(0L.lor(-9223372036854775808L), -9223372036854775808L) + assert_eq!(0L | -9223372036854775808L, -9223372036854775808L) } test "0 | 9223372036854775807 = 9223372036854775807" { - assert_eq!(0L.lor(9223372036854775807L), 9223372036854775807L) + assert_eq!(0L | 9223372036854775807L, 9223372036854775807L) } test "-1 | 0 = -1" { - assert_eq!((-1L).lor(0L), -1L) + assert_eq!(-1L | 0L, -1L) } test "-1 | -1 = -1" { - assert_eq!((-1L).lor(-1L), -1L) + assert_eq!(-1L | -1L, -1L) } test "-1 | 1 = -1" { - assert_eq!((-1L).lor(1L), -1L) + assert_eq!(-1L | 1L, -1L) } test "-1 | 2147483647 = -1" { - assert_eq!((-1L).lor(2147483647L), -1L) + assert_eq!(-1L | 2147483647L, -1L) } test "-1 | -2147483648 = -1" { - assert_eq!((-1L).lor(-2147483648L), -1L) + assert_eq!(-1L | -2147483648L, -1L) } test "-1 | 2147483648 = -1" { - assert_eq!((-1L).lor(2147483648L), -1L) + assert_eq!(-1L | 2147483648L, -1L) } test "-1 | -2147483649 = -1" { - assert_eq!((-1L).lor(-2147483649L), -1L) + assert_eq!(-1L | -2147483649L, -1L) } test "-1 | 9223372036854775807 = -1" { - assert_eq!((-1L).lor(9223372036854775807L), -1L) + assert_eq!(-1L | 9223372036854775807L, -1L) } test "-1 | -9223372036854775808 = -1" { - assert_eq!((-1L).lor(-9223372036854775808L), -1L) + assert_eq!(-1L | -9223372036854775808L, -1L) } test "-1 | -9223372036854775808 = -1" { - assert_eq!((-1L).lor(-9223372036854775808L), -1L) + assert_eq!(-1L | -9223372036854775808L, -1L) } test "-1 | 9223372036854775807 = -1" { - assert_eq!((-1L).lor(9223372036854775807L), -1L) + assert_eq!(-1L | 9223372036854775807L, -1L) } test "1 | 0 = 1" { - assert_eq!(1L.lor(0L), 1L) + assert_eq!(1L | 0L, 1L) } test "1 | -1 = -1" { - assert_eq!(1L.lor(-1L), -1L) + assert_eq!(1L | -1L, -1L) } test "1 | 1 = 1" { - assert_eq!(1L.lor(1L), 1L) + assert_eq!(1L | 1L, 1L) } test "1 | 2147483647 = 2147483647" { - assert_eq!(1L.lor(2147483647L), 2147483647L) + assert_eq!(1L | 2147483647L, 2147483647L) } test "1 | -2147483648 = -2147483647" { - assert_eq!(1L.lor(-2147483648L), -2147483647L) + assert_eq!(1L | -2147483648L, -2147483647L) } test "1 | 2147483648 = 2147483649" { - assert_eq!(1L.lor(2147483648L), 2147483649L) + assert_eq!(1L | 2147483648L, 2147483649L) } test "1 | -2147483649 = -2147483649" { - assert_eq!(1L.lor(-2147483649L), -2147483649L) + assert_eq!(1L | -2147483649L, -2147483649L) } test "1 | 9223372036854775807 = 9223372036854775807" { - assert_eq!(1L.lor(9223372036854775807L), 9223372036854775807L) + assert_eq!(1L | 9223372036854775807L, 9223372036854775807L) } test "1 | -9223372036854775808 = -9223372036854775807" { - assert_eq!(1L.lor(-9223372036854775808L), -9223372036854775807L) + assert_eq!(1L | -9223372036854775808L, -9223372036854775807L) } test "1 | -9223372036854775808 = -9223372036854775807" { - assert_eq!(1L.lor(-9223372036854775808L), -9223372036854775807L) + assert_eq!(1L | -9223372036854775808L, -9223372036854775807L) } test "1 | 9223372036854775807 = 9223372036854775807" { - assert_eq!(1L.lor(9223372036854775807L), 9223372036854775807L) + assert_eq!(1L | 9223372036854775807L, 9223372036854775807L) } test "2147483647 | 0 = 2147483647" { - assert_eq!(2147483647L.lor(0L), 2147483647L) + assert_eq!(2147483647L | 0L, 2147483647L) } test "2147483647 | -1 = -1" { - assert_eq!(2147483647L.lor(-1L), -1L) + assert_eq!(2147483647L | -1L, -1L) } test "2147483647 | 1 = 2147483647" { - assert_eq!(2147483647L.lor(1L), 2147483647L) + assert_eq!(2147483647L | 1L, 2147483647L) } test "2147483647 | 2147483647 = 2147483647" { - assert_eq!(2147483647L.lor(2147483647L), 2147483647L) + assert_eq!(2147483647L | 2147483647L, 2147483647L) } test "2147483647 | -2147483648 = -1" { - assert_eq!(2147483647L.lor(-2147483648L), -1L) + assert_eq!(2147483647L | -2147483648L, -1L) } test "2147483647 | 2147483648 = 4294967295" { - assert_eq!(2147483647L.lor(2147483648L), 4294967295L) + assert_eq!(2147483647L | 2147483648L, 4294967295L) } test "2147483647 | -2147483649 = -2147483649" { - assert_eq!(2147483647L.lor(-2147483649L), -2147483649L) + assert_eq!(2147483647L | -2147483649L, -2147483649L) } test "2147483647 | 9223372036854775807 = 9223372036854775807" { - assert_eq!(2147483647L.lor(9223372036854775807L), 9223372036854775807L) + assert_eq!(2147483647L | 9223372036854775807L, 9223372036854775807L) } test "2147483647 | -9223372036854775808 = -9223372034707292161" { - assert_eq!(2147483647L.lor(-9223372036854775808L), -9223372034707292161L) + assert_eq!(2147483647L | -9223372036854775808L, -9223372034707292161L) } test "2147483647 | -9223372036854775808 = -9223372034707292161" { - assert_eq!(2147483647L.lor(-9223372036854775808L), -9223372034707292161L) + assert_eq!(2147483647L | -9223372036854775808L, -9223372034707292161L) } test "2147483647 | 9223372036854775807 = 9223372036854775807" { - assert_eq!(2147483647L.lor(9223372036854775807L), 9223372036854775807L) + assert_eq!(2147483647L | 9223372036854775807L, 9223372036854775807L) } test "-2147483648 | 0 = -2147483648" { - assert_eq!((-2147483648L).lor(0L), -2147483648L) + assert_eq!(-2147483648L | 0L, -2147483648L) } test "-2147483648 | -1 = -1" { - assert_eq!((-2147483648L).lor(-1L), -1L) + assert_eq!(-2147483648L | -1L, -1L) } test "-2147483648 | 1 = -2147483647" { - assert_eq!((-2147483648L).lor(1L), -2147483647L) + assert_eq!(-2147483648L | 1L, -2147483647L) } test "-2147483648 | 2147483647 = -1" { - assert_eq!((-2147483648L).lor(2147483647L), -1L) + assert_eq!(-2147483648L | 2147483647L, -1L) } test "-2147483648 | -2147483648 = -2147483648" { - assert_eq!((-2147483648L).lor(-2147483648L), -2147483648L) + assert_eq!(-2147483648L | -2147483648L, -2147483648L) } test "-2147483648 | 2147483648 = -2147483648" { - assert_eq!((-2147483648L).lor(2147483648L), -2147483648L) + assert_eq!(-2147483648L | 2147483648L, -2147483648L) } test "-2147483648 | -2147483649 = -1" { - assert_eq!((-2147483648L).lor(-2147483649L), -1L) + assert_eq!(-2147483648L | -2147483649L, -1L) } test "-2147483648 | 9223372036854775807 = -1" { - assert_eq!((-2147483648L).lor(9223372036854775807L), -1L) + assert_eq!(-2147483648L | 9223372036854775807L, -1L) } test "-2147483648 | -9223372036854775808 = -2147483648" { - assert_eq!((-2147483648L).lor(-9223372036854775808L), -2147483648L) + assert_eq!(-2147483648L | -9223372036854775808L, -2147483648L) } test "-2147483648 | -9223372036854775808 = -2147483648" { - assert_eq!((-2147483648L).lor(-9223372036854775808L), -2147483648L) + assert_eq!(-2147483648L | -9223372036854775808L, -2147483648L) } test "-2147483648 | 9223372036854775807 = -1" { - assert_eq!((-2147483648L).lor(9223372036854775807L), -1L) + assert_eq!(-2147483648L | 9223372036854775807L, -1L) } test "2147483648 | 0 = 2147483648" { - assert_eq!(2147483648L.lor(0L), 2147483648L) + assert_eq!(2147483648L | 0L, 2147483648L) } test "2147483648 | -1 = -1" { - assert_eq!(2147483648L.lor(-1L), -1L) + assert_eq!(2147483648L | -1L, -1L) } test "2147483648 | 1 = 2147483649" { - assert_eq!(2147483648L.lor(1L), 2147483649L) + assert_eq!(2147483648L | 1L, 2147483649L) } test "2147483648 | 2147483647 = 4294967295" { - assert_eq!(2147483648L.lor(2147483647L), 4294967295L) + assert_eq!(2147483648L | 2147483647L, 4294967295L) } test "2147483648 | -2147483648 = -2147483648" { - assert_eq!(2147483648L.lor(-2147483648L), -2147483648L) + assert_eq!(2147483648L | -2147483648L, -2147483648L) } test "2147483648 | 2147483648 = 2147483648" { - assert_eq!(2147483648L.lor(2147483648L), 2147483648L) + assert_eq!(2147483648L | 2147483648L, 2147483648L) } test "2147483648 | -2147483649 = -1" { - assert_eq!(2147483648L.lor(-2147483649L), -1L) + assert_eq!(2147483648L | -2147483649L, -1L) } test "2147483648 | 9223372036854775807 = 9223372036854775807" { - assert_eq!(2147483648L.lor(9223372036854775807L), 9223372036854775807L) + assert_eq!(2147483648L | 9223372036854775807L, 9223372036854775807L) } test "2147483648 | -9223372036854775808 = -9223372034707292160" { - assert_eq!(2147483648L.lor(-9223372036854775808L), -9223372034707292160L) + assert_eq!(2147483648L | -9223372036854775808L, -9223372034707292160L) } test "2147483648 | -9223372036854775808 = -9223372034707292160" { - assert_eq!(2147483648L.lor(-9223372036854775808L), -9223372034707292160L) + assert_eq!(2147483648L | -9223372036854775808L, -9223372034707292160L) } test "2147483648 | 9223372036854775807 = 9223372036854775807" { - assert_eq!(2147483648L.lor(9223372036854775807L), 9223372036854775807L) + assert_eq!(2147483648L | 9223372036854775807L, 9223372036854775807L) } test "-2147483649 | 0 = -2147483649" { - assert_eq!((-2147483649L).lor(0L), -2147483649L) + assert_eq!(-2147483649L | 0L, -2147483649L) } test "-2147483649 | -1 = -1" { - assert_eq!((-2147483649L).lor(-1L), -1L) + assert_eq!(-2147483649L | -1L, -1L) } test "-2147483649 | 1 = -2147483649" { - assert_eq!((-2147483649L).lor(1L), -2147483649L) + assert_eq!(-2147483649L | 1L, -2147483649L) } test "-2147483649 | 2147483647 = -2147483649" { - assert_eq!((-2147483649L).lor(2147483647L), -2147483649L) + assert_eq!(-2147483649L | 2147483647L, -2147483649L) } test "-2147483649 | -2147483648 = -1" { - assert_eq!((-2147483649L).lor(-2147483648L), -1L) + assert_eq!(-2147483649L | -2147483648L, -1L) } test "-2147483649 | 2147483648 = -1" { - assert_eq!((-2147483649L).lor(2147483648L), -1L) + assert_eq!(-2147483649L | 2147483648L, -1L) } test "-2147483649 | -2147483649 = -2147483649" { - assert_eq!((-2147483649L).lor(-2147483649L), -2147483649L) + assert_eq!(-2147483649L | -2147483649L, -2147483649L) } test "-2147483649 | 9223372036854775807 = -1" { - assert_eq!((-2147483649L).lor(9223372036854775807L), -1L) + assert_eq!(-2147483649L | 9223372036854775807L, -1L) } test "-2147483649 | -9223372036854775808 = -2147483649" { - assert_eq!((-2147483649L).lor(-9223372036854775808L), -2147483649L) + assert_eq!(-2147483649L | -9223372036854775808L, -2147483649L) } test "-2147483649 | -9223372036854775808 = -2147483649" { - assert_eq!((-2147483649L).lor(-9223372036854775808L), -2147483649L) + assert_eq!(-2147483649L | -9223372036854775808L, -2147483649L) } test "-2147483649 | 9223372036854775807 = -1" { - assert_eq!((-2147483649L).lor(9223372036854775807L), -1L) + assert_eq!(-2147483649L | 9223372036854775807L, -1L) } test "9223372036854775807 | 0 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lor(0L), 9223372036854775807L) + assert_eq!(9223372036854775807L | 0L, 9223372036854775807L) } test "9223372036854775807 | -1 = -1" { - assert_eq!(9223372036854775807L.lor(-1L), -1L) + assert_eq!(9223372036854775807L | -1L, -1L) } test "9223372036854775807 | 1 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lor(1L), 9223372036854775807L) + assert_eq!(9223372036854775807L | 1L, 9223372036854775807L) } test "9223372036854775807 | 2147483647 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lor(2147483647L), 9223372036854775807L) + assert_eq!(9223372036854775807L | 2147483647L, 9223372036854775807L) } test "9223372036854775807 | -2147483648 = -1" { - assert_eq!(9223372036854775807L.lor(-2147483648L), -1L) + assert_eq!(9223372036854775807L | -2147483648L, -1L) } test "9223372036854775807 | 2147483648 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lor(2147483648L), 9223372036854775807L) + assert_eq!(9223372036854775807L | 2147483648L, 9223372036854775807L) } test "9223372036854775807 | -2147483649 = -1" { - assert_eq!(9223372036854775807L.lor(-2147483649L), -1L) + assert_eq!(9223372036854775807L | -2147483649L, -1L) } test "9223372036854775807 | 9223372036854775807 = 9223372036854775807" { - assert_eq!( - 9223372036854775807L.lor(9223372036854775807L), - 9223372036854775807L, - ) + assert_eq!(9223372036854775807L | 9223372036854775807L, 9223372036854775807L) } test "9223372036854775807 | -9223372036854775808 = -1" { - assert_eq!(9223372036854775807L.lor(-9223372036854775808L), -1L) + assert_eq!(9223372036854775807L | -9223372036854775808L, -1L) } test "9223372036854775807 | -9223372036854775808 = -1" { - assert_eq!(9223372036854775807L.lor(-9223372036854775808L), -1L) + assert_eq!(9223372036854775807L | -9223372036854775808L, -1L) } test "9223372036854775807 | 9223372036854775807 = 9223372036854775807" { - assert_eq!( - 9223372036854775807L.lor(9223372036854775807L), - 9223372036854775807L, - ) + assert_eq!(9223372036854775807L | 9223372036854775807L, 9223372036854775807L) } test "-9223372036854775808 | 0 = -9223372036854775808" { - assert_eq!((-9223372036854775808L).lor(0L), -9223372036854775808L) + assert_eq!(-9223372036854775808L | 0L, -9223372036854775808L) } test "-9223372036854775808 | -1 = -1" { - assert_eq!((-9223372036854775808L).lor(-1L), -1L) + assert_eq!(-9223372036854775808L | -1L, -1L) } test "-9223372036854775808 | 1 = -9223372036854775807" { - assert_eq!((-9223372036854775808L).lor(1L), -9223372036854775807L) + assert_eq!(-9223372036854775808L | 1L, -9223372036854775807L) } test "-9223372036854775808 | 2147483647 = -9223372034707292161" { - assert_eq!((-9223372036854775808L).lor(2147483647L), -9223372034707292161L) + assert_eq!(-9223372036854775808L | 2147483647L, -9223372034707292161L) } test "-9223372036854775808 | -2147483648 = -2147483648" { - assert_eq!((-9223372036854775808L).lor(-2147483648L), -2147483648L) + assert_eq!(-9223372036854775808L | -2147483648L, -2147483648L) } test "-9223372036854775808 | 2147483648 = -9223372034707292160" { - assert_eq!((-9223372036854775808L).lor(2147483648L), -9223372034707292160L) + assert_eq!(-9223372036854775808L | 2147483648L, -9223372034707292160L) } test "-9223372036854775808 | -2147483649 = -2147483649" { - assert_eq!((-9223372036854775808L).lor(-2147483649L), -2147483649L) + assert_eq!(-9223372036854775808L | -2147483649L, -2147483649L) } test "-9223372036854775808 | 9223372036854775807 = -1" { - assert_eq!((-9223372036854775808L).lor(9223372036854775807L), -1L) + assert_eq!(-9223372036854775808L | 9223372036854775807L, -1L) } test "-9223372036854775808 | -9223372036854775808 = -9223372036854775808" { assert_eq!( - (-9223372036854775808L).lor(-9223372036854775808L), + -9223372036854775808L | -9223372036854775808L, -9223372036854775808L, ) } test "-9223372036854775808 | -9223372036854775808 = -9223372036854775808" { assert_eq!( - (-9223372036854775808L).lor(-9223372036854775808L), + -9223372036854775808L | -9223372036854775808L, -9223372036854775808L, ) } test "-9223372036854775808 | 9223372036854775807 = -1" { - assert_eq!((-9223372036854775808L).lor(9223372036854775807L), -1L) + assert_eq!(-9223372036854775808L | 9223372036854775807L, -1L) } test "-9223372036854775808 | 0 = -9223372036854775808" { - assert_eq!((-9223372036854775808L).lor(0L), -9223372036854775808L) + assert_eq!(-9223372036854775808L | 0L, -9223372036854775808L) } test "-9223372036854775808 | -1 = -1" { - assert_eq!((-9223372036854775808L).lor(-1L), -1L) + assert_eq!(-9223372036854775808L | -1L, -1L) } test "-9223372036854775808 | 1 = -9223372036854775807" { - assert_eq!((-9223372036854775808L).lor(1L), -9223372036854775807L) + assert_eq!(-9223372036854775808L | 1L, -9223372036854775807L) } test "-9223372036854775808 | 2147483647 = -9223372034707292161" { - assert_eq!((-9223372036854775808L).lor(2147483647L), -9223372034707292161L) + assert_eq!(-9223372036854775808L | 2147483647L, -9223372034707292161L) } test "-9223372036854775808 | -2147483648 = -2147483648" { - assert_eq!((-9223372036854775808L).lor(-2147483648L), -2147483648L) + assert_eq!(-9223372036854775808L | -2147483648L, -2147483648L) } test "-9223372036854775808 | 2147483648 = -9223372034707292160" { - assert_eq!((-9223372036854775808L).lor(2147483648L), -9223372034707292160L) + assert_eq!(-9223372036854775808L | 2147483648L, -9223372034707292160L) } test "-9223372036854775808 | -2147483649 = -2147483649" { - assert_eq!((-9223372036854775808L).lor(-2147483649L), -2147483649L) + assert_eq!(-9223372036854775808L | -2147483649L, -2147483649L) } test "-9223372036854775808 | 9223372036854775807 = -1" { - assert_eq!((-9223372036854775808L).lor(9223372036854775807L), -1L) + assert_eq!(-9223372036854775808L | 9223372036854775807L, -1L) } test "-9223372036854775808 | -9223372036854775808 = -9223372036854775808" { assert_eq!( - (-9223372036854775808L).lor(-9223372036854775808L), + -9223372036854775808L | -9223372036854775808L, -9223372036854775808L, ) } test "-9223372036854775808 | -9223372036854775808 = -9223372036854775808" { assert_eq!( - (-9223372036854775808L).lor(-9223372036854775808L), + -9223372036854775808L | -9223372036854775808L, -9223372036854775808L, ) } test "-9223372036854775808 | 9223372036854775807 = -1" { - assert_eq!((-9223372036854775808L).lor(9223372036854775807L), -1L) + assert_eq!(-9223372036854775808L | 9223372036854775807L, -1L) } test "9223372036854775807 | 0 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lor(0L), 9223372036854775807L) + assert_eq!(9223372036854775807L | 0L, 9223372036854775807L) } test "9223372036854775807 | -1 = -1" { - assert_eq!(9223372036854775807L.lor(-1L), -1L) + assert_eq!(9223372036854775807L | -1L, -1L) } test "9223372036854775807 | 1 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lor(1L), 9223372036854775807L) + assert_eq!(9223372036854775807L | 1L, 9223372036854775807L) } test "9223372036854775807 | 2147483647 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lor(2147483647L), 9223372036854775807L) + assert_eq!(9223372036854775807L | 2147483647L, 9223372036854775807L) } test "9223372036854775807 | -2147483648 = -1" { - assert_eq!(9223372036854775807L.lor(-2147483648L), -1L) + assert_eq!(9223372036854775807L | -2147483648L, -1L) } test "9223372036854775807 | 2147483648 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lor(2147483648L), 9223372036854775807L) + assert_eq!(9223372036854775807L | 2147483648L, 9223372036854775807L) } test "9223372036854775807 | -2147483649 = -1" { - assert_eq!(9223372036854775807L.lor(-2147483649L), -1L) + assert_eq!(9223372036854775807L | -2147483649L, -1L) } test "9223372036854775807 | 9223372036854775807 = 9223372036854775807" { - assert_eq!( - 9223372036854775807L.lor(9223372036854775807L), - 9223372036854775807L, - ) + assert_eq!(9223372036854775807L | 9223372036854775807L, 9223372036854775807L) } test "9223372036854775807 | -9223372036854775808 = -1" { - assert_eq!(9223372036854775807L.lor(-9223372036854775808L), -1L) + assert_eq!(9223372036854775807L | -9223372036854775808L, -1L) } test "9223372036854775807 | -9223372036854775808 = -1" { - assert_eq!(9223372036854775807L.lor(-9223372036854775808L), -1L) + assert_eq!(9223372036854775807L | -9223372036854775808L, -1L) } test "9223372036854775807 | 9223372036854775807 = 9223372036854775807" { - assert_eq!( - 9223372036854775807L.lor(9223372036854775807L), - 9223372036854775807L, - ) + assert_eq!(9223372036854775807L | 9223372036854775807L, 9223372036854775807L) } test "0 ^ 0 = 0" { - assert_eq!(0L.lxor(0L), 0L) + assert_eq!(0L ^ 0L, 0L) } test "0 ^ -1 = -1" { - assert_eq!(0L.lxor(-1L), -1L) + assert_eq!(0L ^ -1L, -1L) } test "0 ^ 1 = 1" { - assert_eq!(0L.lxor(1L), 1L) + assert_eq!(0L ^ 1L, 1L) } test "0 ^ 2147483647 = 2147483647" { - assert_eq!(0L.lxor(2147483647L), 2147483647L) + assert_eq!(0L ^ 2147483647L, 2147483647L) } test "0 ^ -2147483648 = -2147483648" { - assert_eq!(0L.lxor(-2147483648L), -2147483648L) + assert_eq!(0L ^ -2147483648L, -2147483648L) } test "0 ^ 2147483648 = 2147483648" { - assert_eq!(0L.lxor(2147483648L), 2147483648L) + assert_eq!(0L ^ 2147483648L, 2147483648L) } test "0 ^ -2147483649 = -2147483649" { - assert_eq!(0L.lxor(-2147483649L), -2147483649L) + assert_eq!(0L ^ -2147483649L, -2147483649L) } test "0 ^ 9223372036854775807 = 9223372036854775807" { - assert_eq!(0L.lxor(9223372036854775807L), 9223372036854775807L) + assert_eq!(0L ^ 9223372036854775807L, 9223372036854775807L) } test "0 ^ -9223372036854775808 = -9223372036854775808" { - assert_eq!(0L.lxor(-9223372036854775808L), -9223372036854775808L) + assert_eq!(0L ^ -9223372036854775808L, -9223372036854775808L) } test "0 ^ -9223372036854775808 = -9223372036854775808" { - assert_eq!(0L.lxor(-9223372036854775808L), -9223372036854775808L) + assert_eq!(0L ^ -9223372036854775808L, -9223372036854775808L) } test "0 ^ 9223372036854775807 = 9223372036854775807" { - assert_eq!(0L.lxor(9223372036854775807L), 9223372036854775807L) + assert_eq!(0L ^ 9223372036854775807L, 9223372036854775807L) } test "-1 ^ 0 = -1" { - assert_eq!((-1L).lxor(0L), -1L) + assert_eq!(-1L ^ 0L, -1L) } test "-1 ^ -1 = 0" { - assert_eq!((-1L).lxor(-1L), 0L) + assert_eq!(-1L ^ -1L, 0L) } test "-1 ^ 1 = -2" { - assert_eq!((-1L).lxor(1L), -2L) + assert_eq!(-1L ^ 1L, -2L) } test "-1 ^ 2147483647 = -2147483648" { - assert_eq!((-1L).lxor(2147483647L), -2147483648L) + assert_eq!(-1L ^ 2147483647L, -2147483648L) } test "-1 ^ -2147483648 = 2147483647" { - assert_eq!((-1L).lxor(-2147483648L), 2147483647L) + assert_eq!(-1L ^ -2147483648L, 2147483647L) } test "-1 ^ 2147483648 = -2147483649" { - assert_eq!((-1L).lxor(2147483648L), -2147483649L) + assert_eq!(-1L ^ 2147483648L, -2147483649L) } test "-1 ^ -2147483649 = 2147483648" { - assert_eq!((-1L).lxor(-2147483649L), 2147483648L) + assert_eq!(-1L ^ -2147483649L, 2147483648L) } test "-1 ^ 9223372036854775807 = -9223372036854775808" { - assert_eq!((-1L).lxor(9223372036854775807L), -9223372036854775808L) + assert_eq!(-1L ^ 9223372036854775807L, -9223372036854775808L) } test "-1 ^ -9223372036854775808 = 9223372036854775807" { - assert_eq!((-1L).lxor(-9223372036854775808L), 9223372036854775807L) + assert_eq!(-1L ^ -9223372036854775808L, 9223372036854775807L) } test "-1 ^ -9223372036854775808 = 9223372036854775807" { - assert_eq!((-1L).lxor(-9223372036854775808L), 9223372036854775807L) + assert_eq!(-1L ^ -9223372036854775808L, 9223372036854775807L) } test "-1 ^ 9223372036854775807 = -9223372036854775808" { - assert_eq!((-1L).lxor(9223372036854775807L), -9223372036854775808L) + assert_eq!(-1L ^ 9223372036854775807L, -9223372036854775808L) } test "1 ^ 0 = 1" { - assert_eq!(1L.lxor(0L), 1L) + assert_eq!(1L ^ 0L, 1L) } test "1 ^ -1 = -2" { - assert_eq!(1L.lxor(-1L), -2L) + assert_eq!(1L ^ -1L, -2L) } test "1 ^ 1 = 0" { - assert_eq!(1L.lxor(1L), 0L) + assert_eq!(1L ^ 1L, 0L) } test "1 ^ 2147483647 = 2147483646" { - assert_eq!(1L.lxor(2147483647L), 2147483646L) + assert_eq!(1L ^ 2147483647L, 2147483646L) } test "1 ^ -2147483648 = -2147483647" { - assert_eq!(1L.lxor(-2147483648L), -2147483647L) + assert_eq!(1L ^ -2147483648L, -2147483647L) } test "1 ^ 2147483648 = 2147483649" { - assert_eq!(1L.lxor(2147483648L), 2147483649L) + assert_eq!(1L ^ 2147483648L, 2147483649L) } test "1 ^ -2147483649 = -2147483650" { - assert_eq!(1L.lxor(-2147483649L), -2147483650L) + assert_eq!(1L ^ -2147483649L, -2147483650L) } test "1 ^ 9223372036854775807 = 9223372036854775806" { - assert_eq!(1L.lxor(9223372036854775807L), 9223372036854775806L) + assert_eq!(1L ^ 9223372036854775807L, 9223372036854775806L) } test "1 ^ -9223372036854775808 = -9223372036854775807" { - assert_eq!(1L.lxor(-9223372036854775808L), -9223372036854775807L) + assert_eq!(1L ^ -9223372036854775808L, -9223372036854775807L) } test "1 ^ -9223372036854775808 = -9223372036854775807" { - assert_eq!(1L.lxor(-9223372036854775808L), -9223372036854775807L) + assert_eq!(1L ^ -9223372036854775808L, -9223372036854775807L) } test "1 ^ 9223372036854775807 = 9223372036854775806" { - assert_eq!(1L.lxor(9223372036854775807L), 9223372036854775806L) + assert_eq!(1L ^ 9223372036854775807L, 9223372036854775806L) } test "2147483647 ^ 0 = 2147483647" { - assert_eq!(2147483647L.lxor(0L), 2147483647L) + assert_eq!(2147483647L ^ 0L, 2147483647L) } test "2147483647 ^ -1 = -2147483648" { - assert_eq!(2147483647L.lxor(-1L), -2147483648L) + assert_eq!(2147483647L ^ -1L, -2147483648L) } test "2147483647 ^ 1 = 2147483646" { - assert_eq!(2147483647L.lxor(1L), 2147483646L) + assert_eq!(2147483647L ^ 1L, 2147483646L) } test "2147483647 ^ 2147483647 = 0" { - assert_eq!(2147483647L.lxor(2147483647L), 0L) + assert_eq!(2147483647L ^ 2147483647L, 0L) } test "2147483647 ^ -2147483648 = -1" { - assert_eq!(2147483647L.lxor(-2147483648L), -1L) + assert_eq!(2147483647L ^ -2147483648L, -1L) } test "2147483647 ^ 2147483648 = 4294967295" { - assert_eq!(2147483647L.lxor(2147483648L), 4294967295L) + assert_eq!(2147483647L ^ 2147483648L, 4294967295L) } test "2147483647 ^ -2147483649 = -4294967296" { - assert_eq!(2147483647L.lxor(-2147483649L), -4294967296L) + assert_eq!(2147483647L ^ -2147483649L, -4294967296L) } test "2147483647 ^ 9223372036854775807 = 9223372034707292160" { - assert_eq!(2147483647L.lxor(9223372036854775807L), 9223372034707292160L) + assert_eq!(2147483647L ^ 9223372036854775807L, 9223372034707292160L) } test "2147483647 ^ -9223372036854775808 = -9223372034707292161" { - assert_eq!(2147483647L.lxor(-9223372036854775808L), -9223372034707292161L) + assert_eq!(2147483647L ^ -9223372036854775808L, -9223372034707292161L) } test "2147483647 ^ -9223372036854775808 = -9223372034707292161" { - assert_eq!(2147483647L.lxor(-9223372036854775808L), -9223372034707292161L) + assert_eq!(2147483647L ^ -9223372036854775808L, -9223372034707292161L) } test "2147483647 ^ 9223372036854775807 = 9223372034707292160" { - assert_eq!(2147483647L.lxor(9223372036854775807L), 9223372034707292160L) + assert_eq!(2147483647L ^ 9223372036854775807L, 9223372034707292160L) } test "-2147483648 ^ 0 = -2147483648" { - assert_eq!((-2147483648L).lxor(0L), -2147483648L) + assert_eq!(-2147483648L ^ 0L, -2147483648L) } test "-2147483648 ^ -1 = 2147483647" { - assert_eq!((-2147483648L).lxor(-1L), 2147483647L) + assert_eq!(-2147483648L ^ -1L, 2147483647L) } test "-2147483648 ^ 1 = -2147483647" { - assert_eq!((-2147483648L).lxor(1L), -2147483647L) + assert_eq!(-2147483648L ^ 1L, -2147483647L) } test "-2147483648 ^ 2147483647 = -1" { - assert_eq!((-2147483648L).lxor(2147483647L), -1L) + assert_eq!(-2147483648L ^ 2147483647L, -1L) } test "-2147483648 ^ -2147483648 = 0" { - assert_eq!((-2147483648L).lxor(-2147483648L), 0L) + assert_eq!(-2147483648L ^ -2147483648L, 0L) } test "-2147483648 ^ 2147483648 = -4294967296" { - assert_eq!((-2147483648L).lxor(2147483648L), -4294967296L) + assert_eq!(-2147483648L ^ 2147483648L, -4294967296L) } test "-2147483648 ^ -2147483649 = 4294967295" { - assert_eq!((-2147483648L).lxor(-2147483649L), 4294967295L) + assert_eq!(-2147483648L ^ -2147483649L, 4294967295L) } test "-2147483648 ^ 9223372036854775807 = -9223372034707292161" { - assert_eq!((-2147483648L).lxor(9223372036854775807L), -9223372034707292161L) + assert_eq!(-2147483648L ^ 9223372036854775807L, -9223372034707292161L) } test "-2147483648 ^ -9223372036854775808 = 9223372034707292160" { - assert_eq!((-2147483648L).lxor(-9223372036854775808L), 9223372034707292160L) + assert_eq!(-2147483648L ^ -9223372036854775808L, 9223372034707292160L) } test "-2147483648 ^ -9223372036854775808 = 9223372034707292160" { - assert_eq!((-2147483648L).lxor(-9223372036854775808L), 9223372034707292160L) + assert_eq!(-2147483648L ^ -9223372036854775808L, 9223372034707292160L) } test "-2147483648 ^ 9223372036854775807 = -9223372034707292161" { - assert_eq!((-2147483648L).lxor(9223372036854775807L), -9223372034707292161L) + assert_eq!(-2147483648L ^ 9223372036854775807L, -9223372034707292161L) } test "2147483648 ^ 0 = 2147483648" { - assert_eq!(2147483648L.lxor(0L), 2147483648L) + assert_eq!(2147483648L ^ 0L, 2147483648L) } test "2147483648 ^ -1 = -2147483649" { - assert_eq!(2147483648L.lxor(-1L), -2147483649L) + assert_eq!(2147483648L ^ -1L, -2147483649L) } test "2147483648 ^ 1 = 2147483649" { - assert_eq!(2147483648L.lxor(1L), 2147483649L) + assert_eq!(2147483648L ^ 1L, 2147483649L) } test "2147483648 ^ 2147483647 = 4294967295" { - assert_eq!(2147483648L.lxor(2147483647L), 4294967295L) + assert_eq!(2147483648L ^ 2147483647L, 4294967295L) } test "2147483648 ^ -2147483648 = -4294967296" { - assert_eq!(2147483648L.lxor(-2147483648L), -4294967296L) + assert_eq!(2147483648L ^ -2147483648L, -4294967296L) } test "2147483648 ^ 2147483648 = 0" { - assert_eq!(2147483648L.lxor(2147483648L), 0L) + assert_eq!(2147483648L ^ 2147483648L, 0L) } test "2147483648 ^ -2147483649 = -1" { - assert_eq!(2147483648L.lxor(-2147483649L), -1L) + assert_eq!(2147483648L ^ -2147483649L, -1L) } test "2147483648 ^ 9223372036854775807 = 9223372034707292159" { - assert_eq!(2147483648L.lxor(9223372036854775807L), 9223372034707292159L) + assert_eq!(2147483648L ^ 9223372036854775807L, 9223372034707292159L) } test "2147483648 ^ -9223372036854775808 = -9223372034707292160" { - assert_eq!(2147483648L.lxor(-9223372036854775808L), -9223372034707292160L) + assert_eq!(2147483648L ^ -9223372036854775808L, -9223372034707292160L) } test "2147483648 ^ -9223372036854775808 = -9223372034707292160" { - assert_eq!(2147483648L.lxor(-9223372036854775808L), -9223372034707292160L) + assert_eq!(2147483648L ^ -9223372036854775808L, -9223372034707292160L) } test "2147483648 ^ 9223372036854775807 = 9223372034707292159" { - assert_eq!(2147483648L.lxor(9223372036854775807L), 9223372034707292159L) + assert_eq!(2147483648L ^ 9223372036854775807L, 9223372034707292159L) } test "-2147483649 ^ 0 = -2147483649" { - assert_eq!((-2147483649L).lxor(0L), -2147483649L) + assert_eq!(-2147483649L ^ 0L, -2147483649L) } test "-2147483649 ^ -1 = 2147483648" { - assert_eq!((-2147483649L).lxor(-1L), 2147483648L) + assert_eq!(-2147483649L ^ -1L, 2147483648L) } test "-2147483649 ^ 1 = -2147483650" { - assert_eq!((-2147483649L).lxor(1L), -2147483650L) + assert_eq!(-2147483649L ^ 1L, -2147483650L) } test "-2147483649 ^ 2147483647 = -4294967296" { - assert_eq!((-2147483649L).lxor(2147483647L), -4294967296L) + assert_eq!(-2147483649L ^ 2147483647L, -4294967296L) } test "-2147483649 ^ -2147483648 = 4294967295" { - assert_eq!((-2147483649L).lxor(-2147483648L), 4294967295L) + assert_eq!(-2147483649L ^ -2147483648L, 4294967295L) } test "-2147483649 ^ 2147483648 = -1" { - assert_eq!((-2147483649L).lxor(2147483648L), -1L) + assert_eq!(-2147483649L ^ 2147483648L, -1L) } test "-2147483649 ^ -2147483649 = 0" { - assert_eq!((-2147483649L).lxor(-2147483649L), 0L) + assert_eq!(-2147483649L ^ -2147483649L, 0L) } test "-2147483649 ^ 9223372036854775807 = -9223372034707292160" { - assert_eq!((-2147483649L).lxor(9223372036854775807L), -9223372034707292160L) + assert_eq!(-2147483649L ^ 9223372036854775807L, -9223372034707292160L) } test "-2147483649 ^ -9223372036854775808 = 9223372034707292159" { - assert_eq!((-2147483649L).lxor(-9223372036854775808L), 9223372034707292159L) + assert_eq!(-2147483649L ^ -9223372036854775808L, 9223372034707292159L) } test "-2147483649 ^ -9223372036854775808 = 9223372034707292159" { - assert_eq!((-2147483649L).lxor(-9223372036854775808L), 9223372034707292159L) + assert_eq!(-2147483649L ^ -9223372036854775808L, 9223372034707292159L) } test "-2147483649 ^ 9223372036854775807 = -9223372034707292160" { - assert_eq!((-2147483649L).lxor(9223372036854775807L), -9223372034707292160L) + assert_eq!(-2147483649L ^ 9223372036854775807L, -9223372034707292160L) } test "9223372036854775807 ^ 0 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lxor(0L), 9223372036854775807L) + assert_eq!(9223372036854775807L ^ 0L, 9223372036854775807L) } test "9223372036854775807 ^ -1 = -9223372036854775808" { - assert_eq!(9223372036854775807L.lxor(-1L), -9223372036854775808L) + assert_eq!(9223372036854775807L ^ -1L, -9223372036854775808L) } test "9223372036854775807 ^ 1 = 9223372036854775806" { - assert_eq!(9223372036854775807L.lxor(1L), 9223372036854775806L) + assert_eq!(9223372036854775807L ^ 1L, 9223372036854775806L) } test "9223372036854775807 ^ 2147483647 = 9223372034707292160" { - assert_eq!(9223372036854775807L.lxor(2147483647L), 9223372034707292160L) + assert_eq!(9223372036854775807L ^ 2147483647L, 9223372034707292160L) } test "9223372036854775807 ^ -2147483648 = -9223372034707292161" { - assert_eq!(9223372036854775807L.lxor(-2147483648L), -9223372034707292161L) + assert_eq!(9223372036854775807L ^ -2147483648L, -9223372034707292161L) } test "9223372036854775807 ^ 2147483648 = 9223372034707292159" { - assert_eq!(9223372036854775807L.lxor(2147483648L), 9223372034707292159L) + assert_eq!(9223372036854775807L ^ 2147483648L, 9223372034707292159L) } test "9223372036854775807 ^ -2147483649 = -9223372034707292160" { - assert_eq!(9223372036854775807L.lxor(-2147483649L), -9223372034707292160L) + assert_eq!(9223372036854775807L ^ -2147483649L, -9223372034707292160L) } test "9223372036854775807 ^ 9223372036854775807 = 0" { - assert_eq!(9223372036854775807L.lxor(9223372036854775807L), 0L) + assert_eq!(9223372036854775807L ^ 9223372036854775807L, 0L) } test "9223372036854775807 ^ -9223372036854775808 = -1" { - assert_eq!(9223372036854775807L.lxor(-9223372036854775808L), -1L) + assert_eq!(9223372036854775807L ^ -9223372036854775808L, -1L) } test "9223372036854775807 ^ -9223372036854775808 = -1" { - assert_eq!(9223372036854775807L.lxor(-9223372036854775808L), -1L) + assert_eq!(9223372036854775807L ^ -9223372036854775808L, -1L) } test "9223372036854775807 ^ 9223372036854775807 = 0" { - assert_eq!(9223372036854775807L.lxor(9223372036854775807L), 0L) + assert_eq!(9223372036854775807L ^ 9223372036854775807L, 0L) } test "-9223372036854775808 ^ 0 = -9223372036854775808" { - assert_eq!((-9223372036854775808L).lxor(0L), -9223372036854775808L) + assert_eq!(-9223372036854775808L ^ 0L, -9223372036854775808L) } test "-9223372036854775808 ^ -1 = 9223372036854775807" { - assert_eq!((-9223372036854775808L).lxor(-1L), 9223372036854775807L) + assert_eq!(-9223372036854775808L ^ -1L, 9223372036854775807L) } test "-9223372036854775808 ^ 1 = -9223372036854775807" { - assert_eq!((-9223372036854775808L).lxor(1L), -9223372036854775807L) + assert_eq!(-9223372036854775808L ^ 1L, -9223372036854775807L) } test "-9223372036854775808 ^ 2147483647 = -9223372034707292161" { - assert_eq!((-9223372036854775808L).lxor(2147483647L), -9223372034707292161L) + assert_eq!(-9223372036854775808L ^ 2147483647L, -9223372034707292161L) } test "-9223372036854775808 ^ -2147483648 = 9223372034707292160" { - assert_eq!((-9223372036854775808L).lxor(-2147483648L), 9223372034707292160L) + assert_eq!(-9223372036854775808L ^ -2147483648L, 9223372034707292160L) } test "-9223372036854775808 ^ 2147483648 = -9223372034707292160" { - assert_eq!((-9223372036854775808L).lxor(2147483648L), -9223372034707292160L) + assert_eq!(-9223372036854775808L ^ 2147483648L, -9223372034707292160L) } test "-9223372036854775808 ^ -2147483649 = 9223372034707292159" { - assert_eq!((-9223372036854775808L).lxor(-2147483649L), 9223372034707292159L) + assert_eq!(-9223372036854775808L ^ -2147483649L, 9223372034707292159L) } test "-9223372036854775808 ^ 9223372036854775807 = -1" { - assert_eq!((-9223372036854775808L).lxor(9223372036854775807L), -1L) + assert_eq!(-9223372036854775808L ^ 9223372036854775807L, -1L) } test "-9223372036854775808 ^ -9223372036854775808 = 0" { - assert_eq!((-9223372036854775808L).lxor(-9223372036854775808L), 0L) + assert_eq!(-9223372036854775808L ^ -9223372036854775808L, 0L) } test "-9223372036854775808 ^ -9223372036854775808 = 0" { - assert_eq!((-9223372036854775808L).lxor(-9223372036854775808L), 0L) + assert_eq!(-9223372036854775808L ^ -9223372036854775808L, 0L) } test "-9223372036854775808 ^ 9223372036854775807 = -1" { - assert_eq!((-9223372036854775808L).lxor(9223372036854775807L), -1L) + assert_eq!(-9223372036854775808L ^ 9223372036854775807L, -1L) } test "-9223372036854775808 ^ 0 = -9223372036854775808" { - assert_eq!((-9223372036854775808L).lxor(0L), -9223372036854775808L) + assert_eq!(-9223372036854775808L ^ 0L, -9223372036854775808L) } test "-9223372036854775808 ^ -1 = 9223372036854775807" { - assert_eq!((-9223372036854775808L).lxor(-1L), 9223372036854775807L) + assert_eq!(-9223372036854775808L ^ -1L, 9223372036854775807L) } test "-9223372036854775808 ^ 1 = -9223372036854775807" { - assert_eq!((-9223372036854775808L).lxor(1L), -9223372036854775807L) + assert_eq!(-9223372036854775808L ^ 1L, -9223372036854775807L) } test "-9223372036854775808 ^ 2147483647 = -9223372034707292161" { - assert_eq!((-9223372036854775808L).lxor(2147483647L), -9223372034707292161L) + assert_eq!(-9223372036854775808L ^ 2147483647L, -9223372034707292161L) } test "-9223372036854775808 ^ -2147483648 = 9223372034707292160" { - assert_eq!((-9223372036854775808L).lxor(-2147483648L), 9223372034707292160L) + assert_eq!(-9223372036854775808L ^ -2147483648L, 9223372034707292160L) } test "-9223372036854775808 ^ 2147483648 = -9223372034707292160" { - assert_eq!((-9223372036854775808L).lxor(2147483648L), -9223372034707292160L) + assert_eq!(-9223372036854775808L ^ 2147483648L, -9223372034707292160L) } test "-9223372036854775808 ^ -2147483649 = 9223372034707292159" { - assert_eq!((-9223372036854775808L).lxor(-2147483649L), 9223372034707292159L) + assert_eq!(-9223372036854775808L ^ -2147483649L, 9223372034707292159L) } test "-9223372036854775808 ^ 9223372036854775807 = -1" { - assert_eq!((-9223372036854775808L).lxor(9223372036854775807L), -1L) + assert_eq!(-9223372036854775808L ^ 9223372036854775807L, -1L) } test "-9223372036854775808 ^ -9223372036854775808 = 0" { - assert_eq!((-9223372036854775808L).lxor(-9223372036854775808L), 0L) + assert_eq!(-9223372036854775808L ^ -9223372036854775808L, 0L) } test "-9223372036854775808 ^ -9223372036854775808 = 0" { - assert_eq!((-9223372036854775808L).lxor(-9223372036854775808L), 0L) + assert_eq!(-9223372036854775808L ^ -9223372036854775808L, 0L) } test "-9223372036854775808 ^ 9223372036854775807 = -1" { - assert_eq!((-9223372036854775808L).lxor(9223372036854775807L), -1L) + assert_eq!(-9223372036854775808L ^ 9223372036854775807L, -1L) } test "9223372036854775807 ^ 0 = 9223372036854775807" { - assert_eq!(9223372036854775807L.lxor(0L), 9223372036854775807L) + assert_eq!(9223372036854775807L ^ 0L, 9223372036854775807L) } test "9223372036854775807 ^ -1 = -9223372036854775808" { - assert_eq!(9223372036854775807L.lxor(-1L), -9223372036854775808L) + assert_eq!(9223372036854775807L ^ -1L, -9223372036854775808L) } test "9223372036854775807 ^ 1 = 9223372036854775806" { - assert_eq!(9223372036854775807L.lxor(1L), 9223372036854775806L) + assert_eq!(9223372036854775807L ^ 1L, 9223372036854775806L) } test "9223372036854775807 ^ 2147483647 = 9223372034707292160" { - assert_eq!(9223372036854775807L.lxor(2147483647L), 9223372034707292160L) + assert_eq!(9223372036854775807L ^ 2147483647L, 9223372034707292160L) } test "9223372036854775807 ^ -2147483648 = -9223372034707292161" { - assert_eq!(9223372036854775807L.lxor(-2147483648L), -9223372034707292161L) + assert_eq!(9223372036854775807L ^ -2147483648L, -9223372034707292161L) } test "9223372036854775807 ^ 2147483648 = 9223372034707292159" { - assert_eq!(9223372036854775807L.lxor(2147483648L), 9223372034707292159L) + assert_eq!(9223372036854775807L ^ 2147483648L, 9223372034707292159L) } test "9223372036854775807 ^ -2147483649 = -9223372034707292160" { - assert_eq!(9223372036854775807L.lxor(-2147483649L), -9223372034707292160L) + assert_eq!(9223372036854775807L ^ -2147483649L, -9223372034707292160L) } test "9223372036854775807 ^ 9223372036854775807 = 0" { - assert_eq!(9223372036854775807L.lxor(9223372036854775807L), 0L) + assert_eq!(9223372036854775807L ^ 9223372036854775807L, 0L) } test "9223372036854775807 ^ -9223372036854775808 = -1" { - assert_eq!(9223372036854775807L.lxor(-9223372036854775808L), -1L) + assert_eq!(9223372036854775807L ^ -9223372036854775808L, -1L) } test "9223372036854775807 ^ -9223372036854775808 = -1" { - assert_eq!(9223372036854775807L.lxor(-9223372036854775808L), -1L) + assert_eq!(9223372036854775807L ^ -9223372036854775808L, -1L) } test "9223372036854775807 ^ 9223372036854775807 = 0" { - assert_eq!(9223372036854775807L.lxor(9223372036854775807L), 0L) + assert_eq!(9223372036854775807L ^ 9223372036854775807L, 0L) } test "0 << 0 = 0" { @@ -4670,355 +4658,355 @@ test "9223372036854775807 >>> 65 = 4611686018427387903" { } test "0 >> 0 = 0" { - assert_eq!(0L.shr(0), 0L) + assert_eq!(0L >> 0, 0L) } test "0 >> 1 = 0" { - assert_eq!(0L.shr(1), 0L) + assert_eq!(0L >> 1, 0L) } test "0 >> 31 = 0" { - assert_eq!(0L.shr(31), 0L) + assert_eq!(0L >> 31, 0L) } test "0 >> 32 = 0" { - assert_eq!(0L.shr(32), 0L) + assert_eq!(0L >> 32, 0L) } test "0 >> 33 = 0" { - assert_eq!(0L.shr(33), 0L) + assert_eq!(0L >> 33, 0L) } test "0 >> 63 = 0" { - assert_eq!(0L.shr(63), 0L) + assert_eq!(0L >> 63, 0L) } test "0 >> 64 = 0" { - assert_eq!(0L.shr(64), 0L) + assert_eq!(0L >> 64, 0L) } test "0 >> 65 = 0" { - assert_eq!(0L.shr(65), 0L) + assert_eq!(0L >> 65, 0L) } test "-1 >> 0 = -1" { - assert_eq!((-1L).shr(0), -1L) + assert_eq!(-1L >> 0, -1L) } test "-1 >> 1 = -1" { - assert_eq!((-1L).shr(1), -1L) + assert_eq!(-1L >> 1, -1L) } test "-1 >> 31 = -1" { - assert_eq!((-1L).shr(31), -1L) + assert_eq!(-1L >> 31, -1L) } test "-1 >> 32 = -1" { - assert_eq!((-1L).shr(32), -1L) + assert_eq!(-1L >> 32, -1L) } test "-1 >> 33 = -1" { - assert_eq!((-1L).shr(33), -1L) + assert_eq!(-1L >> 33, -1L) } test "-1 >> 63 = -1" { - assert_eq!((-1L).shr(63), -1L) + assert_eq!(-1L >> 63, -1L) } test "-1 >> 64 = -1" { - assert_eq!((-1L).shr(64), -1L) + assert_eq!(-1L >> 64, -1L) } test "-1 >> 65 = -1" { - assert_eq!((-1L).shr(65), -1L) + assert_eq!(-1L >> 65, -1L) } test "1 >> 0 = 1" { - assert_eq!(1L.shr(0), 1L) + assert_eq!(1L >> 0, 1L) } test "1 >> 1 = 0" { - assert_eq!(1L.shr(1), 0L) + assert_eq!(1L >> 1, 0L) } test "1 >> 31 = 0" { - assert_eq!(1L.shr(31), 0L) + assert_eq!(1L >> 31, 0L) } test "1 >> 32 = 0" { - assert_eq!(1L.shr(32), 0L) + assert_eq!(1L >> 32, 0L) } test "1 >> 33 = 0" { - assert_eq!(1L.shr(33), 0L) + assert_eq!(1L >> 33, 0L) } test "1 >> 63 = 0" { - assert_eq!(1L.shr(63), 0L) + assert_eq!(1L >> 63, 0L) } test "1 >> 64 = 1" { - assert_eq!(1L.shr(64), 1L) + assert_eq!(1L >> 64, 1L) } test "1 >> 65 = 0" { - assert_eq!(1L.shr(65), 0L) + assert_eq!(1L >> 65, 0L) } test "2147483647 >> 0 = 2147483647" { - assert_eq!(2147483647L.shr(0), 2147483647L) + assert_eq!(2147483647L >> 0, 2147483647L) } test "2147483647 >> 1 = 1073741823" { - assert_eq!(2147483647L.shr(1), 1073741823L) + assert_eq!(2147483647L >> 1, 1073741823L) } test "2147483647 >> 31 = 0" { - assert_eq!(2147483647L.shr(31), 0L) + assert_eq!(2147483647L >> 31, 0L) } test "2147483647 >> 32 = 0" { - assert_eq!(2147483647L.shr(32), 0L) + assert_eq!(2147483647L >> 32, 0L) } test "2147483647 >> 33 = 0" { - assert_eq!(2147483647L.shr(33), 0L) + assert_eq!(2147483647L >> 33, 0L) } test "2147483647 >> 63 = 0" { - assert_eq!(2147483647L.shr(63), 0L) + assert_eq!(2147483647L >> 63, 0L) } test "2147483647 >> 64 = 2147483647" { - assert_eq!(2147483647L.shr(64), 2147483647L) + assert_eq!(2147483647L >> 64, 2147483647L) } test "2147483647 >> 65 = 1073741823" { - assert_eq!(2147483647L.shr(65), 1073741823L) + assert_eq!(2147483647L >> 65, 1073741823L) } test "-2147483648 >> 0 = -2147483648" { - assert_eq!((-2147483648L).shr(0), -2147483648L) + assert_eq!(-2147483648L >> 0, -2147483648L) } test "-2147483648 >> 1 = -1073741824" { - assert_eq!((-2147483648L).shr(1), -1073741824L) + assert_eq!(-2147483648L >> 1, -1073741824L) } test "-2147483648 >> 31 = -1" { - assert_eq!((-2147483648L).shr(31), -1L) + assert_eq!(-2147483648L >> 31, -1L) } test "-2147483648 >> 32 = -1" { - assert_eq!((-2147483648L).shr(32), -1L) + assert_eq!(-2147483648L >> 32, -1L) } test "-2147483648 >> 33 = -1" { - assert_eq!((-2147483648L).shr(33), -1L) + assert_eq!(-2147483648L >> 33, -1L) } test "-2147483648 >> 63 = -1" { - assert_eq!((-2147483648L).shr(63), -1L) + assert_eq!(-2147483648L >> 63, -1L) } test "-2147483648 >> 64 = -2147483648" { - assert_eq!((-2147483648L).shr(64), -2147483648L) + assert_eq!(-2147483648L >> 64, -2147483648L) } test "-2147483648 >> 65 = -1073741824" { - assert_eq!((-2147483648L).shr(65), -1073741824L) + assert_eq!(-2147483648L >> 65, -1073741824L) } test "2147483648 >> 0 = 2147483648" { - assert_eq!(2147483648L.shr(0), 2147483648L) + assert_eq!(2147483648L >> 0, 2147483648L) } test "2147483648 >> 1 = 1073741824" { - assert_eq!(2147483648L.shr(1), 1073741824L) + assert_eq!(2147483648L >> 1, 1073741824L) } test "2147483648 >> 31 = 1" { - assert_eq!(2147483648L.shr(31), 1L) + assert_eq!(2147483648L >> 31, 1L) } test "2147483648 >> 32 = 0" { - assert_eq!(2147483648L.shr(32), 0L) + assert_eq!(2147483648L >> 32, 0L) } test "2147483648 >> 33 = 0" { - assert_eq!(2147483648L.shr(33), 0L) + assert_eq!(2147483648L >> 33, 0L) } test "2147483648 >> 63 = 0" { - assert_eq!(2147483648L.shr(63), 0L) + assert_eq!(2147483648L >> 63, 0L) } test "2147483648 >> 64 = 2147483648" { - assert_eq!(2147483648L.shr(64), 2147483648L) + assert_eq!(2147483648L >> 64, 2147483648L) } test "2147483648 >> 65 = 1073741824" { - assert_eq!(2147483648L.shr(65), 1073741824L) + assert_eq!(2147483648L >> 65, 1073741824L) } test "-2147483649 >> 0 = -2147483649" { - assert_eq!((-2147483649L).shr(0), -2147483649L) + assert_eq!(-2147483649L >> 0, -2147483649L) } test "-2147483649 >> 1 = -1073741825" { - assert_eq!((-2147483649L).shr(1), -1073741825L) + assert_eq!(-2147483649L >> 1, -1073741825L) } test "-2147483649 >> 31 = -2" { - assert_eq!((-2147483649L).shr(31), -2L) + assert_eq!(-2147483649L >> 31, -2L) } test "-2147483649 >> 32 = -1" { - assert_eq!((-2147483649L).shr(32), -1L) + assert_eq!(-2147483649L >> 32, -1L) } test "-2147483649 >> 33 = -1" { - assert_eq!((-2147483649L).shr(33), -1L) + assert_eq!(-2147483649L >> 33, -1L) } test "-2147483649 >> 63 = -1" { - assert_eq!((-2147483649L).shr(63), -1L) + assert_eq!(-2147483649L >> 63, -1L) } test "-2147483649 >> 64 = -2147483649" { - assert_eq!((-2147483649L).shr(64), -2147483649L) + assert_eq!(-2147483649L >> 64, -2147483649L) } test "-2147483649 >> 65 = -1073741825" { - assert_eq!((-2147483649L).shr(65), -1073741825L) + assert_eq!(-2147483649L >> 65, -1073741825L) } test "9223372036854775807 >> 0 = 9223372036854775807" { - assert_eq!(9223372036854775807L.shr(0), 9223372036854775807L) + assert_eq!(9223372036854775807L >> 0, 9223372036854775807L) } test "9223372036854775807 >> 1 = 4611686018427387903" { - assert_eq!(9223372036854775807L.shr(1), 4611686018427387903L) + assert_eq!(9223372036854775807L >> 1, 4611686018427387903L) } test "9223372036854775807 >> 31 = 4294967295" { - assert_eq!(9223372036854775807L.shr(31), 4294967295L) + assert_eq!(9223372036854775807L >> 31, 4294967295L) } test "9223372036854775807 >> 32 = 2147483647" { - assert_eq!(9223372036854775807L.shr(32), 2147483647L) + assert_eq!(9223372036854775807L >> 32, 2147483647L) } test "9223372036854775807 >> 33 = 1073741823" { - assert_eq!(9223372036854775807L.shr(33), 1073741823L) + assert_eq!(9223372036854775807L >> 33, 1073741823L) } test "9223372036854775807 >> 63 = 0" { - assert_eq!(9223372036854775807L.shr(63), 0L) + assert_eq!(9223372036854775807L >> 63, 0L) } test "9223372036854775807 >> 64 = 9223372036854775807" { - assert_eq!(9223372036854775807L.shr(64), 9223372036854775807L) + assert_eq!(9223372036854775807L >> 64, 9223372036854775807L) } test "9223372036854775807 >> 65 = 4611686018427387903" { - assert_eq!(9223372036854775807L.shr(65), 4611686018427387903L) + assert_eq!(9223372036854775807L >> 65, 4611686018427387903L) } test "-9223372036854775808 >> 0 = -9223372036854775808" { - assert_eq!((-9223372036854775808L).shr(0), -9223372036854775808L) + assert_eq!(-9223372036854775808L >> 0, -9223372036854775808L) } test "-9223372036854775808 >> 1 = -4611686018427387904" { - assert_eq!((-9223372036854775808L).shr(1), -4611686018427387904L) + assert_eq!(-9223372036854775808L >> 1, -4611686018427387904L) } test "-9223372036854775808 >> 31 = -4294967296" { - assert_eq!((-9223372036854775808L).shr(31), -4294967296L) + assert_eq!(-9223372036854775808L >> 31, -4294967296L) } test "-9223372036854775808 >> 32 = -2147483648" { - assert_eq!((-9223372036854775808L).shr(32), -2147483648L) + assert_eq!(-9223372036854775808L >> 32, -2147483648L) } test "-9223372036854775808 >> 33 = -1073741824" { - assert_eq!((-9223372036854775808L).shr(33), -1073741824L) + assert_eq!(-9223372036854775808L >> 33, -1073741824L) } test "-9223372036854775808 >> 63 = -1" { - assert_eq!((-9223372036854775808L).shr(63), -1L) + assert_eq!(-9223372036854775808L >> 63, -1L) } test "-9223372036854775808 >> 64 = -9223372036854775808" { - assert_eq!((-9223372036854775808L).shr(64), -9223372036854775808L) + assert_eq!(-9223372036854775808L >> 64, -9223372036854775808L) } test "-9223372036854775808 >> 65 = -4611686018427387904" { - assert_eq!((-9223372036854775808L).shr(65), -4611686018427387904L) + assert_eq!(-9223372036854775808L >> 65, -4611686018427387904L) } test "-9223372036854775808 >> 0 = -9223372036854775808" { - assert_eq!((-9223372036854775808L).shr(0), -9223372036854775808L) + assert_eq!(-9223372036854775808L >> 0, -9223372036854775808L) } test "-9223372036854775808 >> 1 = -4611686018427387904" { - assert_eq!((-9223372036854775808L).shr(1), -4611686018427387904L) + assert_eq!(-9223372036854775808L >> 1, -4611686018427387904L) } test "-9223372036854775808 >> 31 = -4294967296" { - assert_eq!((-9223372036854775808L).shr(31), -4294967296L) + assert_eq!(-9223372036854775808L >> 31, -4294967296L) } test "-9223372036854775808 >> 32 = -2147483648" { - assert_eq!((-9223372036854775808L).shr(32), -2147483648L) + assert_eq!(-9223372036854775808L >> 32, -2147483648L) } test "-9223372036854775808 >> 33 = -1073741824" { - assert_eq!((-9223372036854775808L).shr(33), -1073741824L) + assert_eq!(-9223372036854775808L >> 33, -1073741824L) } test "-9223372036854775808 >> 63 = -1" { - assert_eq!((-9223372036854775808L).shr(63), -1L) + assert_eq!(-9223372036854775808L >> 63, -1L) } test "-9223372036854775808 >> 64 = -9223372036854775808" { - assert_eq!((-9223372036854775808L).shr(64), -9223372036854775808L) + assert_eq!(-9223372036854775808L >> 64, -9223372036854775808L) } test "-9223372036854775808 >> 65 = -4611686018427387904" { - assert_eq!((-9223372036854775808L).shr(65), -4611686018427387904L) + assert_eq!(-9223372036854775808L >> 65, -4611686018427387904L) } test "9223372036854775807 >> 0 = 9223372036854775807" { - assert_eq!(9223372036854775807L.shr(0), 9223372036854775807L) + assert_eq!(9223372036854775807L >> 0, 9223372036854775807L) } test "9223372036854775807 >> 1 = 4611686018427387903" { - assert_eq!(9223372036854775807L.shr(1), 4611686018427387903L) + assert_eq!(9223372036854775807L >> 1, 4611686018427387903L) } test "9223372036854775807 >> 31 = 4294967295" { - assert_eq!(9223372036854775807L.shr(31), 4294967295L) + assert_eq!(9223372036854775807L >> 31, 4294967295L) } test "9223372036854775807 >> 32 = 2147483647" { - assert_eq!(9223372036854775807L.shr(32), 2147483647L) + assert_eq!(9223372036854775807L >> 32, 2147483647L) } test "9223372036854775807 >> 33 = 1073741823" { - assert_eq!(9223372036854775807L.shr(33), 1073741823L) + assert_eq!(9223372036854775807L >> 33, 1073741823L) } test "9223372036854775807 >> 63 = 0" { - assert_eq!(9223372036854775807L.shr(63), 0L) + assert_eq!(9223372036854775807L >> 63, 0L) } test "9223372036854775807 >> 64 = 9223372036854775807" { - assert_eq!(9223372036854775807L.shr(64), 9223372036854775807L) + assert_eq!(9223372036854775807L >> 64, 9223372036854775807L) } test "9223372036854775807 >> 65 = 4611686018427387903" { - assert_eq!(9223372036854775807L.shr(65), 4611686018427387903L) + assert_eq!(9223372036854775807L >> 65, 4611686018427387903L) } test "compare(0, 0) = 0" { diff --git a/builtin/intrinsics_test.mbt b/builtin/intrinsics_test.mbt index 579265b66..80a9242d0 100644 --- a/builtin/intrinsics_test.mbt +++ b/builtin/intrinsics_test.mbt @@ -16,26 +16,26 @@ test "Int::land should perform bitwise AND operation" { let a = 0b101 let b = 0b011 - inspect!(a.land(b), content="1") - inspect!((0xffff_ffff).land(0xa000_0000) == 0xa000_0000, content="true") - inspect!((0xffff_ffff).land(0x0) == 0, content="true") - inspect!((0xffff_ffff).land(0xffff_ffff) == 0xffff_ffff, content="true") + inspect!(a & b, content="1") + inspect!((0xffff_ffff & 0xa000_0000) == 0xa000_0000, content="true") + inspect!((0xffff_ffff & 0x0) == 0, content="true") + inspect!((0xffff_ffff & 0xffff_ffff) == 0xffff_ffff, content="true") } /// test Int::lor test "Int::lor should perform bitwise OR operation" { - inspect!((0b101).lor(0b011) == 0b111, content="true") - inspect!((0xffff_ffff).lor(0xa000_0000) == 0xffff_ffff, content="true") - inspect!((0xffff_ffff).lor(0x0) == 0xffff_ffff, content="true") - inspect!((0xffff_ffff).lor(0xffff_ffff) == 0xffff_ffff, content="true") + inspect!((0b101 | 0b011) == 0b111, content="true") + inspect!((0xffff_ffff | 0xa000_0000) == 0xffff_ffff, content="true") + inspect!((0xffff_ffff | 0x0) == 0xffff_ffff, content="true") + inspect!((0xffff_ffff | 0xffff_ffff) == 0xffff_ffff, content="true") } /// test Int::lxor test "Int::lxor should perform bitwise XOR operation" { - inspect!((0b101).lxor(0b011) == 0b110, content="true") - inspect!((0xffff_ffff).lxor(0xa000_0000) == 0x5fff_ffff, content="true") - inspect!((0xffff_ffff).lxor(0x0) == 0xffff_ffff, content="true") - inspect!((0xffff_ffff).lxor(0xffff_ffff) == 0, content="true") + inspect!((0b101 ^ 0b011) == 0b110, content="true") + inspect!((0xffff_ffff ^ 0xa000_0000) == 0x5fff_ffff, content="true") + inspect!((0xffff_ffff ^ 0x0) == 0xffff_ffff, content="true") + inspect!((0xffff_ffff ^ 0xffff_ffff) == 0, content="true") } /// test Int::lsl @@ -87,9 +87,9 @@ test "uint test" { inspect!(2147483647U * 2U, content="4294967294") inspect!(0x80000000U / 2U, content="1073741824") inspect!(4294967295U % 17U, content="0") - inspect!(0xFFFFFFFFU.land(0xFFFFU), content="65535") - inspect!(0xFF00U.lor(0xFFU), content="65535") - inspect!(0xFFFF00U.lxor(0xFF00FFU), content="65535") + inspect!(0xFFFFFFFFU & 0xFFFFU, content="65535") + inspect!(0xFF00U | 0xFFU, content="65535") + inspect!(0xFFFF00U ^ 0xFF00FFU, content="65535") inspect!(0x1U.lsl(31), content="2147483648") inspect!(2147483648U.lsr(31), content="1") } @@ -107,9 +107,9 @@ test "uint64 test" { inspect!(9223372036854775808UL * 2UL, content="0") inspect!(0x8000000000000000UL / 2UL, content="4611686018427387904") inspect!(18446744073709551615UL % 17UL, content="0") - inspect!(0xFFFFFFFFUL.land(0xFFFFUL), content="65535") - inspect!(0xFF00UL.lor(0xFFUL), content="65535") - inspect!(0xFFFF00UL.lxor(0xFF00FFUL), content="65535") + inspect!(0xFFFFFFFFUL & 0xFFFFUL, content="65535") + inspect!(0xFF00UL | 0xFFUL, content="65535") + inspect!(0xFFFF00UL ^ 0xFF00FFUL, content="65535") inspect!(0x1UL.lsl(63), content="9223372036854775808") inspect!(9223372036854775808UL.lsr(63), content="1") } diff --git a/builtin/linked_hash_map.mbt b/builtin/linked_hash_map.mbt index fc526ea85..1846f2898 100644 --- a/builtin/linked_hash_map.mbt +++ b/builtin/linked_hash_map.mbt @@ -114,11 +114,7 @@ pub fn set[K : Hash + Eq, V](self : Map[K, V], key : K, value : V) -> Unit { } let hash = key.hash() let insert_entry = { idx: -1, psl: 0, hash, key, value } - loop - 0, - hash.land(self.capacity_mask), - insert_entry, - { prev: None, next: None } { + loop 0, hash & self.capacity_mask, insert_entry, { prev: None, next: None } { i, idx, entry, node => match self.entries[idx] { None => { @@ -141,12 +137,12 @@ pub fn set[K : Hash + Eq, V](self : Map[K, V], key : K, value : V) -> Unit { entry.idx = idx curr_entry.psl += 1 continue i + 1, - (idx + 1).land(self.capacity_mask), + (idx + 1) & self.capacity_mask, curr_entry, curr_node } else { entry.psl += 1 - continue i + 1, (idx + 1).land(self.capacity_mask), entry, node + continue i + 1, (idx + 1) & self.capacity_mask, entry, node } } } @@ -160,7 +156,7 @@ pub fn op_set[K : Hash + Eq, V](self : Map[K, V], key : K, value : V) -> Unit { /// Get the value associated with a key. pub fn get[K : Hash + Eq, V](self : Map[K, V], key : K) -> V? { let hash = key.hash() - for i = 0, idx = hash.land(self.capacity_mask) { + for i = 0, idx = hash & self.capacity_mask { match self.entries[idx] { Some(entry) => { if entry.hash == hash && entry.key == key { @@ -169,7 +165,7 @@ pub fn get[K : Hash + Eq, V](self : Map[K, V], key : K) -> V? { if i > entry.psl { break None } - continue i + 1, (idx + 1).land(self.capacity_mask) + continue i + 1, (idx + 1) & self.capacity_mask } None => break None } @@ -220,7 +216,7 @@ pub fn contains[K : Hash + Eq, V](self : Map[K, V], key : K) -> Bool { /// Remove a key-value pair from hash map. pub fn remove[K : Hash + Eq, V](self : Map[K, V], key : K) -> Unit { let hash = key.hash() - for i = 0, idx = hash.land(self.capacity_mask) { + for i = 0, idx = hash & self.capacity_mask { match self.entries[idx] { Some(entry) => { if entry.hash == hash && entry.key == key { @@ -233,7 +229,7 @@ pub fn remove[K : Hash + Eq, V](self : Map[K, V], key : K) -> Unit { if i > entry.psl { break } - continue i + 1, (idx + 1).land(self.capacity_mask) + continue i + 1, (idx + 1) & self.capacity_mask } None => break } @@ -280,7 +276,7 @@ fn remove_entry[K : Eq, V](self : Map[K, V], entry : Entry[K, V]) -> Unit { } fn shift_back[K : Hash, V](self : Map[K, V], start_index : Int) -> Unit { - for prev = start_index, curr = (start_index + 1).land(self.capacity_mask) { + for prev = start_index, curr = (start_index + 1) & self.capacity_mask { match (self.entries[curr], self.list[curr]) { (Some(entry), currNode) => { if entry.psl == 0 { @@ -294,7 +290,7 @@ fn shift_back[K : Hash, V](self : Map[K, V], start_index : Int) -> Unit { self.list[prev].next = currNode.next currNode.prev = None currNode.next = None - continue curr, (curr + 1).land(self.capacity_mask) + continue curr, (curr + 1) & self.capacity_mask } (None, _) => break } diff --git a/bytes/xxhash.mbt b/bytes/xxhash.mbt index dd521239d..6ae6a1791 100644 --- a/bytes/xxhash.mbt +++ b/bytes/xxhash.mbt @@ -32,7 +32,7 @@ fn xxhash32(input : Bytes, seed : Int) -> Int { seed + gPRIME5 }) + len - finalize(h, input, len.land(-16), len.land(0xF)) + finalize(h, input, len & -16, len & 0xF) } pub impl Hash for Bytes with hash(self) { xxhash32(self, 0) } @@ -42,7 +42,7 @@ pub impl Hash for Bytes with hash_combine(self, hasher) { } fn rotl(x : Int, r : Int) -> Int { - x.lsl(r).lor(x.lsr(32 - r)) + x.lsl(r) | x.lsr(32 - r) } fn round(acc : Int, input : Int) -> Int { @@ -50,7 +50,7 @@ fn round(acc : Int, input : Int) -> Int { } fn avalanche_step(h : Int, rshift : Int, prime : Int) -> Int { - h.lxor(h.lsr(rshift)) * prime + (h ^ h.lsr(rshift)) * prime } fn avalanche(h : Int) -> Int { @@ -62,13 +62,10 @@ fn avalanche(h : Int) -> Int { } fn endian32(input : Bytes, cur : Int) -> Int { - input[cur + 0] - .to_int() - .lor( - input[cur + 1] - .to_int() - .lsl(8) - .lor(input[cur + 2].to_int().lsl(16).lor(input[cur + 3].to_int().lsl(24))), + input[cur + 0].to_int() | + ( + input[cur + 1].to_int().lsl(8) | + (input[cur + 2].to_int().lsl(16) | input[cur + 3].to_int().lsl(24)) ) } diff --git a/double/double.mbt b/double/double.mbt index e2038ffcb..6da84a24b 100644 --- a/double/double.mbt +++ b/double/double.mbt @@ -47,7 +47,7 @@ pub fn trunc(self : Double) -> Double { if biased_exp >= 1075 { return self } - u64.land(sign_mask.shr(biased_exp - 1012)).reinterpret_as_double() + u64.land(sign_mask >> (biased_exp - 1012)).reinterpret_as_double() } test "trunc" { @@ -120,9 +120,9 @@ pub fn round(self : Double) -> Double { .reinterpret_as_double() } let trunced = u64 - .land(sign_mask.shr(biased_exp - 1012)) + .land(sign_mask >> (biased_exp - 1012)) .reinterpret_as_double() - if u64.land(sign_mask.lsr(biased_exp - 1011)) == 0L { + if (u64 & sign_mask.lsr(biased_exp - 1011)) == 0L { return trunced } else if self > 0.0 { return trunced + 1.0 diff --git a/double/internal/ryu/ryu.mbt b/double/internal/ryu/ryu.mbt index a3a28a55e..2e5314479 100644 --- a/double/internal/ryu/ryu.mbt +++ b/double/internal/ryu/ryu.mbt @@ -38,7 +38,7 @@ fn umul128(a : UInt64, b : UInt64) -> (UInt64, UInt64) { } fn shiftright128(lo : UInt64, hi : UInt64, dist : Int) -> UInt64 { - hi.lsl(64 - dist).lor(lo.lsr(dist)) + hi.lsl(64 - dist) | lo.lsr(dist) } fn pow5Factor(value : UInt64) -> Int { @@ -72,7 +72,7 @@ fn multipleOfPowerOf5(value : UInt64, p : Int) -> Bool { } fn multipleOfPowerOf2(value : UInt64, p : Int) -> Bool { - value.land(1UL.lsl(p) - 1UL) == 0UL + (value & (1UL.lsl(p) - 1UL)) == 0UL } fn mulShiftAll64( @@ -288,12 +288,13 @@ fn d2d(ieeeMantissa : UInt64, ieeeExponent : UInt) -> FloatingDecimal64 { gDOUBLE_BIAS - gDOUBLE_MANTISSA_BITS - 2 - m2 = 1UL.lsl(gDOUBLE_MANTISSA_BITS).lor(ieeeMantissa) + m2 = 1UL.lsl(gDOUBLE_MANTISSA_BITS) | ieeeMantissa } - let even = m2.land(1UL) == 0UL + let even = (m2 & 1UL) == 0UL + let mv = 4UL * - // Step 2: Determine the interval of valid decimal representations. - let mv = 4UL * m2 + // Step 2: Determine the interval of valid decimal representations. + m2 // Implicit bool -> int conversion. True is 1, false is 0. let mmShift = ieeeMantissa != 0UL || ieeeExponent <= 1 // We would compute mp and mm like this: @@ -562,7 +563,7 @@ fn d2d_small_int( ieeeMantissa : UInt64, ieeeExponent : Int ) -> FloatingDecimal64? { - let m2 : UInt64 = 1UL.lsl(gDOUBLE_MANTISSA_BITS).lor(ieeeMantissa) + let m2 : UInt64 = 1UL.lsl(gDOUBLE_MANTISSA_BITS) | ieeeMantissa let e2 : Int = ieeeExponent - gDOUBLE_BIAS - gDOUBLE_MANTISSA_BITS if e2 > 0 { return None @@ -571,7 +572,7 @@ fn d2d_small_int( return None } let mask : UInt64 = 1UL.lsl(-e2) - 1UL - let fraction : UInt64 = m2.land(mask) + let fraction : UInt64 = m2 & mask if fraction != 0UL { return None } @@ -586,11 +587,9 @@ pub fn ryu_to_string(val : Double) -> String { let bits : UInt64 = val.reinterpret_as_u64() // Decode bits into sign, mantissa, and exponent. - let ieeeSign = bits - .lsr(gDOUBLE_MANTISSA_BITS + gDOUBLE_EXPONENT_BITS) - .land(1UL) != + let ieeeSign = (bits.lsr(gDOUBLE_MANTISSA_BITS + gDOUBLE_EXPONENT_BITS) & 1UL) != 0UL - let ieeeMantissa : UInt64 = bits.land(1UL.lsl(gDOUBLE_MANTISSA_BITS) - 1UL) + let ieeeMantissa : UInt64 = bits & (1UL.lsl(gDOUBLE_MANTISSA_BITS) - 1UL) let ieeeExponent : Int = bits .lsr(gDOUBLE_MANTISSA_BITS) .land(1UL.lsl(gDOUBLE_EXPONENT_BITS) - 1UL) diff --git a/hashmap/hashmap.mbt b/hashmap/hashmap.mbt index 475633bb3..79a3f09d6 100644 --- a/hashmap/hashmap.mbt +++ b/hashmap/hashmap.mbt @@ -55,7 +55,7 @@ pub fn set[K : Hash + Eq, V](self : T[K, V], key : K, value : V) -> Unit { self.grow() } let hash = key.hash() - for idx = hash.land(self.capacity - 1), entry = { psl: 0, hash, key, value } { + for idx = hash & (self.capacity - 1), entry = { psl: 0, hash, key, value } { match self.entries[idx] { None => { self.entries[idx] = Some(entry) @@ -134,7 +134,7 @@ pub fn contains[K : Hash + Eq, V](self : T[K, V], key : K) -> Bool { /// Remove a key-value pair from hash map. pub fn remove[K : Hash + Eq, V](self : T[K, V], key : K) -> Unit { let hash = key.hash() - for i = 0, idx = hash.land(self.capacity - 1) { + for i = 0, idx = hash & (self.capacity - 1) { match self.entries[idx] { Some(entry) => { if entry.hash == hash && entry.key == key { @@ -146,7 +146,7 @@ pub fn remove[K : Hash + Eq, V](self : T[K, V], key : K) -> Unit { if i > entry.psl { break } - continue i + 1, (idx + 1).land(self.capacity - 1) + continue i + 1, (idx + 1) & (self.capacity - 1) } None => break } @@ -154,7 +154,7 @@ pub fn remove[K : Hash + Eq, V](self : T[K, V], key : K) -> Unit { } fn shift_back[K : Hash, V](self : T[K, V], start_index : Int) -> Unit { - for prev = start_index, curr = (start_index + 1).land(self.capacity - 1) { + for prev = start_index, curr = (start_index + 1) & (self.capacity - 1) { match self.entries[curr] { Some({ psl, hash, key, value, .. }) => { if psl == 0 { @@ -162,7 +162,7 @@ fn shift_back[K : Hash, V](self : T[K, V], start_index : Int) -> Unit { } self.entries[prev] = Some({ psl: psl - 1, hash, key, value }) self.entries[curr] = None - continue curr, (curr + 1).land(self.capacity - 1) + continue curr, (curr + 1) & (self.capacity - 1) } None => break } diff --git a/hashset/hashset.mbt b/hashset/hashset.mbt index 54265bd82..bc0073d02 100644 --- a/hashset/hashset.mbt +++ b/hashset/hashset.mbt @@ -254,7 +254,7 @@ fn grow[K : Hash + Eq](self : T[K]) -> Unit { } fn index[K : Hash](self : T[K], hash : Int) -> Int { - abs(hash).land(self.capacity - 1) + abs(hash) & (self.capacity - 1) } fn abs(n : Int) -> Int { @@ -266,7 +266,7 @@ fn abs(n : Int) -> Int { } fn next_index[K : Hash](self : T[K], index : Int) -> Int { - (index + 1).land(self.capacity - 1) + (index + 1) & (self.capacity - 1) } fn calc_grow_threshold(capacity : Int) -> Int { diff --git a/immut/array/array.mbt b/immut/array/array.mbt index 8f567d8b4..2bf22c6d7 100644 --- a/immut/array/array.mbt +++ b/immut/array/array.mbt @@ -106,9 +106,9 @@ pub fn op_get[A](self : T[A], index : Int) -> A { pub fn set[A](self : T[A], index : Int, value : A) -> T[A] { fn set(i : Int, e, s, t : Tree[A]) -> Tree[A] { match t { - Leaf(l) => Leaf(immutable_set(l, i.land(bitmask), e)) + Leaf(l) => Leaf(immutable_set(l, i & bitmask, e)) Node(node) => { - let idx = i.lsr(s).land(bitmask) + let idx = i.lsr(s) & bitmask Node(immutable_set(node, idx, set(i, e, s - num_bits, node[idx]))) } Empty => abort("Index out of bounds") diff --git a/immut/array/tree.mbt b/immut/array/tree.mbt index d10f71413..c5e6ecc45 100644 --- a/immut/array/tree.mbt +++ b/immut/array/tree.mbt @@ -40,9 +40,8 @@ fn get_last[T](self : Tree[T]) -> T { fn get[T](self : Tree[T], index : Int, shift : Int) -> T { match self { - Leaf(leaf) => leaf[index.land(bitmask)] - Node(node) => - get(node[index.lsr(shift).land(bitmask)], index, shift - num_bits) + Leaf(leaf) => leaf[index & bitmask] + Node(node) => get(node[index.lsr(shift) & bitmask], index, shift - num_bits) Empty => abort("Index out of bounds") } } @@ -65,7 +64,7 @@ fn add[T](self : Tree[T], index : Int, shift : Int, value : T) -> Tree[T] { match self { Leaf(l) => Leaf(immutable_push(l, value)) Node(n) => { - let idx = index.lsr(shift).land(bitmask) + let idx = index.lsr(shift) & bitmask if idx < n.length() { Node(immutable_set(n, idx, n[idx].add(index, shift - num_bits, value))) } else { diff --git a/immut/hashmap/HAMT.mbt b/immut/hashmap/HAMT.mbt index 215b00a3a..a86e6eff0 100644 --- a/immut/hashmap/HAMT.mbt +++ b/immut/hashmap/HAMT.mbt @@ -53,7 +53,7 @@ pub fn find[K : Eq + Hash, V](self : T[K, V], key : K) -> V? { // get the first segment (lower 5 bits) of the hash value // inline the hot path of Sparse_array::op_get Branch(children), hash => { - let idx = hash.land(segment_mask) + let idx = hash & segment_mask if children.elem_info.has(idx) { let child = children.data[children.elem_info.index_of(idx)] continue child, hash.lsr(segment_length) @@ -79,7 +79,7 @@ fn add_with_hash[K : Eq, V]( if depth >= 32 { T::Leaf(key, value) } else { - let idx = hash.land(segment_mask) + let idx = hash & segment_mask let child = make_leaf( depth + segment_length, key, @@ -100,7 +100,7 @@ fn add_with_hash[K : Eq, V]( } Collision(bucket) => Collision(bucket.add(key, value)) Branch(children) => { - let idx = hash.land(segment_mask) + let idx = hash & segment_mask match children[idx] { Some(child) => { let child = child.add_with_hash( @@ -153,7 +153,7 @@ fn remove_with_hash[K : Eq, V]( Some(new_bucket) => Collision(new_bucket) } Branch(children) => { - let idx = hash.land(segment_mask) + let idx = hash & segment_mask match children[idx] { None => self Some(child) => { diff --git a/immut/hashset/HAMT.mbt b/immut/hashset/HAMT.mbt index 09c39e546..49ed70e22 100644 --- a/immut/hashset/HAMT.mbt +++ b/immut/hashset/HAMT.mbt @@ -53,7 +53,7 @@ pub fn contains[A : Eq + Hash](self : T[A], key : A) -> Bool { // get the first segment (lower 5 bits) of the hash value // inline the hot path of Sparse_array::op_get Branch(children), hash => { - let idx = hash.land(segment_mask) + let idx = hash & segment_mask if children.elem_info.has(idx) { let child = children.data[children.elem_info.index_of(idx)] continue child, hash.lsr(segment_length) @@ -69,7 +69,7 @@ fn add_with_hash[A : Eq](self : T[A], key : A, depth : Int, hash : Int) -> T[A] if depth >= 32 { Leaf(key) } else { - let idx = hash.land(segment_mask) + let idx = hash & segment_mask let child = make_leaf( depth + segment_length, key, @@ -89,7 +89,7 @@ fn add_with_hash[A : Eq](self : T[A], key : A, depth : Int, hash : Int) -> T[A] } Collision(bucket) => Collision(bucket.add(key)) Branch(children) => { - let idx = hash.land(segment_mask) + let idx = hash & segment_mask match children[idx] { Some(child) => { let child = child.add_with_hash( @@ -138,7 +138,7 @@ fn remove_with_hash[A : Eq]( Some(new_bucket) => Collision(new_bucket) } Branch(children) => { - let idx = hash.land(segment_mask) + let idx = hash & segment_mask match children[idx] { None => self Some(child) => { diff --git a/immut/internal/sparse_array/bitset.mbt b/immut/internal/sparse_array/bitset.mbt index cf67ce11d..5743e289a 100644 --- a/immut/internal/sparse_array/bitset.mbt +++ b/immut/internal/sparse_array/bitset.mbt @@ -21,7 +21,7 @@ let empty_bitset : Bitset = Bitset(0) /// /// Check if the given index is present in the bitset. pub fn has(self : Bitset, idx : Int) -> Bool { - self._.land((1).lsl(idx)) != 0 + (self._ & (1).lsl(idx)) != 0 } /// `index_of(self: Bitset, idx: Int)` @@ -35,14 +35,14 @@ pub fn index_of(self : Bitset, idx : Int) -> Int { /// /// Add a new index to the bitset. pub fn add(self : Bitset, idx : Int) -> Bitset { - Bitset(self._.lor((1).lsl(idx))) + Bitset(self._ | (1).lsl(idx)) } /// `remove(self: Bitset, idx: Int)` /// /// Remove an index from the bitset. pub fn remove(self : Bitset, idx : Int) -> Bitset { - Bitset(self._.lxor((1).lsl(idx))) + Bitset(self._ ^ (1).lsl(idx)) } /// `size(self: Bitset) -> Int` diff --git a/int64/xxhash.mbt b/int64/xxhash.mbt index 5603fcdad..5ad602595 100644 --- a/int64/xxhash.mbt +++ b/int64/xxhash.mbt @@ -31,16 +31,16 @@ pub impl Hash for Int64 with hash(self) -> Int { let mut acc = seed + gPRIME5 + 8 let mut x = acc + input.to_int() * gPRIME3 let r = 17 - acc = x.lsl(r).lor(x.lsr(32 - r)) * gPRIME4 + acc = (x.lsl(r) | x.lsr(32 - r)) * gPRIME4 input = input.lsr(32) x = acc + input.to_int() * gPRIME3 - acc = x.lsl(r).lor(x.lsr(32 - r)) * gPRIME4 + acc = (x.lsl(r) | x.lsr(32 - r)) * gPRIME4 input = input.lsr(32) - acc = acc.lxor(acc.lsr(15)) + acc = acc ^ acc.lsr(15) acc *= gPRIME2 - acc = acc.lxor(acc.lsr(13)) + acc = acc ^ acc.lsr(13) acc *= gPRIME3 - acc = acc.lxor(acc.lsr(16)) + acc = acc ^ acc.lsr(16) acc } diff --git a/json/lex_string.mbt b/json/lex_string.mbt index d04050166..048ee819f 100644 --- a/json/lex_string.mbt +++ b/json/lex_string.mbt @@ -66,17 +66,17 @@ fn lex_hex_digits(ctx : ParseContext, n : Int) -> Int!ParseError { match read_char(ctx) { Some(c) => if c >= 'A' { - let d = c.to_int().land((32).lnot()) - 'A'.to_int() + 10 + let d = (c.to_int() & (32).lnot()) - 'A'.to_int() + 10 if d > 15 { invalid_char!(ctx, shift=-1) } - r = r.lsl(4).lor(d) + r = r.lsl(4) | d } else if c >= '0' { let d = c.to_int() - '0'.to_int() if d > 9 { invalid_char!(ctx, shift=-1) } - r = r.lsl(4).lor(d) + r = r.lsl(4) | d } else { invalid_char!(ctx, shift=-1) } diff --git a/math/trigonometric.mbt b/math/trigonometric.mbt index 32411dae1..cfb27d322 100644 --- a/math/trigonometric.mbt +++ b/math/trigonometric.mbt @@ -38,11 +38,11 @@ pub fn sin(x : Double) -> Double { sign = true } let mut j = (x_ * pi4).to_int64() - if j.land(1L) == 1L { + if (j & 1L) == 1L { j += 1L } let y = j.to_double() - j = j.land(7L) + j = j & 7L if j > 3L { sign = sign.not() j -= 4L @@ -91,11 +91,11 @@ pub fn cos(x : Double) -> Double { let mut sign = false let x_ = x.abs() let mut j = (x_ * pi4).to_int64() - if j.land(1L) == 1L { + if (j & 1L) == 1L { j += 1L } let y = j.to_double() - j = j.land(7L) + j = j & 7L if j > 3L { sign = sign.not() j -= 4L @@ -150,7 +150,7 @@ pub fn tan(x : Double) -> Double { } else { let x_ = x.abs() let mut j = (x_ * pi4).to_int64() - if j.land(1L) == 1L { + if (j & 1L) == 1L { j += 1L } let y = j.to_double() @@ -167,7 +167,7 @@ pub fn tan(x : Double) -> Double { } else { z } - if j.land(2L) == 2L { + if (j & 2L) == 2L { zz = -1.0 / zz } if x.signum() < 0.0 { diff --git a/random/splitmix/random.mbt b/random/splitmix/random.mbt index 8b7506905..b7c4750c7 100644 --- a/random/splitmix/random.mbt +++ b/random/splitmix/random.mbt @@ -68,7 +68,7 @@ pub fn split(self : RandomState) -> RandomState { } fn shift_xor(n : Int, w : UInt64) -> UInt64 { - w.lxor(w.lsr(n)) + w ^ w.lsr(n) } fn shift_xor_mul(n : Int, k : UInt64, w : UInt64) -> UInt64 { diff --git a/strconv/decimal.mbt b/strconv/decimal.mbt index 43d03ca6a..73723caa5 100644 --- a/strconv/decimal.mbt +++ b/strconv/decimal.mbt @@ -212,7 +212,7 @@ pub fn to_double(self : Decimal) -> Double!StrConvError { } // denormalized - if mantissa.land(1L.lsl(double_info.mantissa_bits)) == 0L { + if (mantissa & 1L.lsl(double_info.mantissa_bits)) == 0L { exponent = double_info.bias } @@ -247,17 +247,16 @@ pub fn shift(self : Decimal, s : Int) -> Unit { fn assemble_bits(mantissa : Int64, exponent : Int, negative : Bool) -> Int64 { let biased_exp = exponent - double_info.bias // set the mantissa bits - let mut bits = mantissa.land(1L.lsl(double_info.mantissa_bits) - 1L) + let mut bits = mantissa & (1L.lsl(double_info.mantissa_bits) - 1L) // set the exponent bits let exp_bits = biased_exp .land((1).lsl(double_info.exponent_bits) - 1) .to_int64() - bits = bits.lor(exp_bits.lsl(double_info.mantissa_bits)) + bits = bits | exp_bits.lsl(double_info.mantissa_bits) // set the sign bit if negative { - bits = bits.lor( - 1L.lsl(double_info.mantissa_bits).lsl(double_info.exponent_bits), - ) + bits = bits | + 1L.lsl(double_info.mantissa_bits).lsl(double_info.exponent_bits) } bits } @@ -356,7 +355,7 @@ fn right_shift(self : Decimal, s : Int) -> Unit { self.digits[write_index] = out.to_byte() write_index += 1 // contract - acc = acc.land(mask) + acc = acc & mask // expand let d = self.digits[read_index] acc = acc * 10L + d.to_int64() @@ -372,7 +371,7 @@ fn right_shift(self : Decimal, s : Int) -> Unit { } else if out > 0 { self.truncated = true } - acc = acc.land(mask) + acc = acc & mask acc = acc * 10L } diff --git a/strconv/double.mbt b/strconv/double.mbt index 9fb8c7808..4d3c65684 100644 --- a/strconv/double.mbt +++ b/strconv/double.mbt @@ -89,7 +89,7 @@ let table = [ ] fn pow10_fast_path(exponent : Int) -> Double { - table[exponent.land(31)] + table[exponent & 31] } let int_pow10 : Array[UInt64] = [