signed int bitwise

This commit is contained in:
jangko 2023-06-13 22:17:43 +07:00
parent 612ecb3d9b
commit f2959e5135
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
5 changed files with 19 additions and 369 deletions

View File

@ -161,11 +161,14 @@ func `xor`*(a, b: StInt): StInt =
func `shr`*(a: StInt, k: SomeInteger): StInt =
## Shift right by k bits, arithmetically
## ~(~a >> k)
var tmp: type a
result.imp.bitnot(a.imp)
tmp.imp.shiftRight(result.imp, k)
result.imp.bitnot(tmp.imp)
## value < 0 ? ~(~value >> amount) : value >> amount
if a.isNegative:
var tmp: type a
result.imp.bitnot(a.imp)
tmp.imp.shiftRight(result.imp, k)
result.imp.bitnot(tmp.imp)
else:
result.imp.shiftRight(a.imp, k)
func `shl`*(a: StInt, k: SomeInteger): StInt =
## Shift left by k bits

View File

@ -299,8 +299,7 @@ func toString*[bits: static[int]](num: StInt[bits], radix: static[int8] = 10): s
## - they are prefixed with "-" for base 10.
## - if not base 10, they are returned raw in two-complement form.
let isNeg = num.isNegative
#if radix == 10 and isNeg:
if isNeg:
if radix == 10 and isNeg:
"-" & toString(num.neg.imp, radix)
else:
toString(num.imp, radix)

View File

@ -19,14 +19,16 @@ import
#test_uint_modular_arithmetic,
test_uint_mul
#[
import test_int_endianness,
test_int_comparison,
test_int_addsub,
test_int_muldiv,
test_int_boundchecks,
test_int_bitwise
import
test_int_signedness,
test_int_initialization,
test_int_comparison,
test_int_bitwise,
test_int_addsub,
#[
test_int_endianness,
test_int_muldiv,
import test_io,
test_conversion
]#

View File

@ -41,34 +41,6 @@ template chkAbs(chk, a, b, bits: untyped) =
template testAddSub(chk, tst: untyped) =
tst "addition":
chkAddition(chk, 0'i8, 0'i8, 0'i8, 8)
chkAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 8)
chkAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 8)
chkAddition(chk, 0'i8, 0'i8, 0'i8, 16)
chkAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 16)
chkAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 16)
chkAddition(chk, high(int16) - 17'i16, 17'i16, high(int16), 16)
chkAddition(chk, low(int16) + 17'i16, 17'i16, low(int16) + 34'i16, 16)
chkAddition(chk, 0'i8, 0'i8, 0'i8, 32)
chkAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 32)
chkAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 32)
chkAddition(chk, high(int16) - 17'i16, 17'i16, high(int16), 32)
chkAddition(chk, low(int16) + 17'i16, 17'i16, low(int16) + 34'i16, 32)
chkAddition(chk, high(int32) - 17'i32, 17'i32, high(int32), 32)
chkAddition(chk, low(int32) + 17'i32, 17'i32, low(int32) + 34'i32, 32)
chkAddition(chk, 0'i8, 0'i8, 0'i8, 64)
chkAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 64)
chkAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 64)
chkAddition(chk, high(int16) - 17'i16, 17'i16, high(int16), 64)
chkAddition(chk, low(int16) + 17'i16, 17'i16, low(int16) + 34'i16, 64)
chkAddition(chk, high(int32) - 17'i32, 17'i32, high(int32), 64)
chkAddition(chk, low(int32) + 17'i32, 17'i32, low(int32) + 34'i32, 64)
chkAddition(chk, high(int64) - 17'i64, 17'i64, high(int64), 64)
chkAddition(chk, low(int64) + 17'i64, 17'i64, low(int64) + 34'i64, 64)
chkAddition(chk, 0'i8, 0'i8, 0'i8, 128)
chkAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 128)
chkAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 128)
@ -80,34 +52,6 @@ template testAddSub(chk, tst: untyped) =
chkAddition(chk, low(int64) + 17'i64, 17'i64, low(int64) + 34'i64, 128)
tst "inplace addition":
chkInplaceAddition(chk, 0'i8, 0'i8, 0'i8, 8)
chkInplaceAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 8)
chkInplaceAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 8)
chkInplaceAddition(chk, 0'i8, 0'i8, 0'i8, 16)
chkInplaceAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 16)
chkInplaceAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 16)
chkInplaceAddition(chk, high(int16) - 17'i16, 17'i16, high(int16), 16)
chkInplaceAddition(chk, low(int16) + 17'i16, 17'i16, low(int16) + 34'i16, 16)
chkInplaceAddition(chk, 0'i8, 0'i8, 0'i8, 32)
chkInplaceAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 32)
chkInplaceAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 32)
chkInplaceAddition(chk, high(int16) - 17'i16, 17'i16, high(int16), 32)
chkInplaceAddition(chk, low(int16) + 17'i16, 17'i16, low(int16) + 34'i16, 32)
chkInplaceAddition(chk, high(int32) - 17'i32, 17'i32, high(int32), 32)
chkInplaceAddition(chk, low(int32) + 17'i32, 17'i32, low(int32) + 34'i32, 32)
chkInplaceAddition(chk, 0'i8, 0'i8, 0'i8, 64)
chkInplaceAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 64)
chkInplaceAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 64)
chkInplaceAddition(chk, high(int16) - 17'i16, 17'i16, high(int16), 64)
chkInplaceAddition(chk, low(int16) + 17'i16, 17'i16, low(int16) + 34'i16, 64)
chkInplaceAddition(chk, high(int32) - 17'i32, 17'i32, high(int32), 64)
chkInplaceAddition(chk, low(int32) + 17'i32, 17'i32, low(int32) + 34'i32, 64)
chkInplaceAddition(chk, high(int64) - 17'i64, 17'i64, high(int64), 64)
chkInplaceAddition(chk, low(int64) + 17'i64, 17'i64, low(int64) + 34'i64, 64)
chkInplaceAddition(chk, 0'i8, 0'i8, 0'i8, 128)
chkInplaceAddition(chk, high(int8) - 17'i8, 17'i8, high(int8), 128)
chkInplaceAddition(chk, low(int8) + 17'i8, 17'i8, low(int8) + 34'i8, 128)
@ -119,34 +63,6 @@ template testAddSub(chk, tst: untyped) =
chkInplaceAddition(chk, low(int64) + 17'i64, 17'i64, low(int64) + 34'i64, 128)
tst "substraction":
chkSubstraction(chk, 0'i8, 0'i8, 0'i8, 8)
chkSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 8)
chkSubstraction(chk, low(int8) + 17'i8, 17'i8, low(int8), 8)
chkSubstraction(chk, 0'i8, 0'i8, 0'i8, 16)
chkSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 16)
chkSubstraction(chk, low(int8) + 17'i8, 17'i8, low(int8), 16)
chkSubstraction(chk, high(int16) - 17'i16, 17'i16, high(int16) - 34'i16, 16)
chkSubstraction(chk, low(int16) + 17'i16, 17'i16, low(int16), 16)
chkSubstraction(chk, 0'i8, 0'i8, 0'i8, 32)
chkSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 32)
chkSubstraction(chk, low(int8) + 17'i8, 17'i8, low(int8), 32)
chkSubstraction(chk, high(int16) - 17'i16, 17'i16, high(int16) - 34'i16, 32)
chkSubstraction(chk, low(int16) + 17'i16, 17'i16, low(int16), 32)
chkSubstraction(chk, high(int32) - 17'i32, 17'i32, high(int32) - 34'i32, 32)
chkSubstraction(chk, low(int32) + 17'i32, 17'i32, low(int32), 32)
chkSubstraction(chk, 0'i8, 0'i8, 0'i8, 64)
chkSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 64)
chkSubstraction(chk, low(int8) + 17'i8, 17'i8, low(int8), 64)
chkSubstraction(chk, high(int16) - 17'i16, 17'i16, high(int16) - 34'i16, 64)
chkSubstraction(chk, low(int16) + 17'i16, 17'i16, low(int16), 64)
chkSubstraction(chk, high(int32) - 17'i32, 17'i32, high(int32) - 34'i32, 64)
chkSubstraction(chk, low(int32) + 17'i32, 17'i32, low(int32), 64)
chkSubstraction(chk, high(int64) - 17'i64, 17'i64, high(int64) - 34'i64, 64)
chkSubstraction(chk, low(int64) + 17'i64, 17'i64, low(int64), 64)
chkSubstraction(chk, 0'i8, 0'i8, 0'i8, 128)
chkSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 128)
chkSubstraction(chk, -high(int8), -high(int8), 0'i8, 128)
@ -158,34 +74,6 @@ template testAddSub(chk, tst: untyped) =
chkSubstraction(chk, -high(int64), -high(int64), 0'i64, 128)
tst "inplace substraction":
chkInplaceSubstraction(chk, 0'i8, 0'i8, 0'i8, 8)
chkInplaceSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 8)
chkInplaceSubstraction(chk, low(int8) + 17'i8, 17'i8, low(int8), 8)
chkInplaceSubstraction(chk, 0'i8, 0'i8, 0'i8, 16)
chkInplaceSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 16)
chkInplaceSubstraction(chk, low(int8) + 17'i8, 17'i8, low(int8), 16)
chkInplaceSubstraction(chk, high(int16) - 17'i16, 17'i16, high(int16) - 34'i16, 16)
chkInplaceSubstraction(chk, low(int16) + 17'i16, 17'i16, low(int16), 16)
chkInplaceSubstraction(chk, 0'i8, 0'i8, 0'i8, 32)
chkInplaceSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 32)
chkInplaceSubstraction(chk, low(int8) + 17'i8, 17'i8, low(int8), 32)
chkInplaceSubstraction(chk, high(int16) - 17'i16, 17'i16, high(int16) - 34'i16, 32)
chkInplaceSubstraction(chk, low(int16) + 17'i16, 17'i16, low(int16), 32)
chkInplaceSubstraction(chk, high(int32) - 17'i32, 17'i32, high(int32) - 34'i32, 32)
chkInplaceSubstraction(chk, low(int32) + 17'i32, 17'i32, low(int32), 32)
chkInplaceSubstraction(chk, 0'i8, 0'i8, 0'i8, 64)
chkInplaceSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 64)
chkInplaceSubstraction(chk, low(int8) + 17'i8, 17'i8, low(int8), 64)
chkInplaceSubstraction(chk, high(int16) - 17'i16, 17'i16, high(int16) - 34'i16, 64)
chkInplaceSubstraction(chk, low(int16) + 17'i16, 17'i16, low(int16), 64)
chkInplaceSubstraction(chk, high(int32) - 17'i32, 17'i32, high(int32) - 34'i32, 64)
chkInplaceSubstraction(chk, low(int32) + 17'i32, 17'i32, low(int32), 64)
chkInplaceSubstraction(chk, high(int64) - 17'i64, 17'i64, high(int64) - 34'i64, 64)
chkInplaceSubstraction(chk, low(int64) + 17'i64, 17'i64, low(int64), 64)
chkInplaceSubstraction(chk, 0'i8, 0'i8, 0'i8, 128)
chkInplaceSubstraction(chk, high(int8) - 17'i8, 17'i8, high(int8) - 34'i8, 128)
chkInplaceSubstraction(chk, -high(int8), -high(int8), 0'i8, 128)
@ -197,32 +85,6 @@ template testAddSub(chk, tst: untyped) =
chkInplaceSubstraction(chk, -high(int64), -high(int64), 0'i64, 128)
tst "negation":
chkNegation(chk, 0, 0, 8)
# chkNegation(chk, 128, -128, 8) # TODO: bug #92
chkNegation(chk, 127, -127, 8)
chkNegation(chk, 0, 0, 16)
chkNegation(chk, 128, -128, 16)
chkNegation(chk, 127, -127, 16)
#chkNegation(chk, 32768, -32768, 16) # TODO: bug #92
chkNegation(chk, 32767, -32767, 16)
chkNegation(chk, 0, 0, 32)
chkNegation(chk, 128, -128, 32)
chkNegation(chk, 127, -127, 32)
chkNegation(chk, 32768, -32768, 32)
chkNegation(chk, 32767, -32767, 32)
#chkNegation(chk, high(int32)+1, low(int32), 32) # TODO: bug #92
chkNegation(chk, 0, 0, 64)
chkNegation(chk, 128, -128, 64)
chkNegation(chk, 127, -127, 64)
chkNegation(chk, 32768, -32768, 64)
chkNegation(chk, 32767, -32767, 64)
chkNegation(chk, 2147483648, -2147483648, 64)
chkNegation(chk, 2147483647, -2147483647, 64)
#chkNegation(chk, 9223372036854775808, -9223372036854775808, 64) # TODO: bug #92
chkNegation(chk, 0, 0, 128)
chkNegation(chk, 128, -128, 128)
chkNegation(chk, 127, -127, 128)
@ -236,42 +98,6 @@ template testAddSub(chk, tst: untyped) =
#chkNegation(chk, 9223372036854775808, -9223372036854775808, 128) # TODO: bug #92
tst "absolute integer":
chkAbs(chk, 0, 0, 8)
chkAbs(chk, -127, 127, 8)
chkAbs(chk, -1, 1, 8)
chkAbs(chk, 1, 1, 8)
chkAbs(chk, 127, 127, 8)
chkAbs(chk, 0, 0, 16)
chkAbs(chk, -127, 127, 16)
chkAbs(chk, -32767, 32767, 16)
chkAbs(chk, -1, 1, 16)
chkAbs(chk, 1, 1, 16)
chkAbs(chk, 127, 127, 16)
chkAbs(chk, 32767, 32767, 16)
chkAbs(chk, 0, 0, 32)
chkAbs(chk, -127, 127, 32)
chkAbs(chk, -32767, 32767, 32)
chkAbs(chk, -1, 1, 32)
chkAbs(chk, 1, 1, 32)
chkAbs(chk, 127, 127, 32)
chkAbs(chk, 32767, 32767, 32)
chkAbs(chk, -2147483647, 2147483647, 32)
chkAbs(chk, 2147483647, 2147483647, 32)
chkAbs(chk, 0, 0, 64)
chkAbs(chk, -127, 127, 64)
chkAbs(chk, -32767, 32767, 64)
chkAbs(chk, -1, 1, 64)
chkAbs(chk, 1, 1, 64)
chkAbs(chk, 127, 127, 64)
chkAbs(chk, 32767, 32767, 64)
chkAbs(chk, -2147483647, 2147483647, 64)
chkAbs(chk, 2147483647, 2147483647, 64)
chkAbs(chk, -9223372036854775807, 9223372036854775807, 64)
chkAbs(chk, 9223372036854775807, 9223372036854775807, 64)
chkAbs(chk, 0, 0, 128)
chkAbs(chk, -127, 127, 128)
chkAbs(chk, -32767, 32767, 128)

View File

@ -33,89 +33,17 @@ template chkShr(chk: untyped, a: string, b: SomeInteger, c: string, bits: int) =
template testBitwise(chk, tst: untyped) =
# TODO: see issue #95
#chkShl(chk, "0F", 8, "00", 8)
#chkShl(chk, "0F", 16, "00", 16)
#chkShl(chk, "0F", 32, "00", 32)
#chkShl(chk, "0F", 64, "00", 64)
#chkShl(chk, "0F", 128, "00", 128)
#chkShl(chk, "0F", 256, "00", 256)
#
#chkShr(chk, "F0", 8, "00", 8)
#chkShr(chk, "F000", 16, "00", 16)
#chkShr(chk, "F0000000", 32, "00", 32)
#chkShr(chk, "F000000000000000", 64, "00", 64)
#chkShr(chk, "F0000000000000000000000000000000", 128, "00", 128)
tst "operator `not`":
chkNot(chk, 0'i8, not 0'i8, 8)
chkNot(chk, high(int8), not high(int8), 8)
chkNot(chk, "0F", "F0", 8)
chkNot(chk, "F0", "0F", 8)
chkNot(chk, 0'i8, not 0'i16, 16)
chkNot(chk, 0'i16, not 0'i16, 16)
chkNot(chk, high(int8), not int16(high(int8)), 16)
chkNot(chk, high(int16), not high(int16), 16)
chkNot(chk, "F0", "FF0F", 16)
chkNot(chk, "0F", "FFF0", 16)
chkNot(chk, "FF00", "00FF", 16)
chkNot(chk, "00FF", "FF00", 16)
chkNot(chk, "0FF0", "F00F", 16)
chkNot(chk, 0'i8, not 0'i32, 32)
chkNot(chk, 0'i16, not 0'i32, 32)
chkNot(chk, 0'i32, not 0'i32, 32)
chkNot(chk, high(int8), not int32(high(int8)), 32)
chkNot(chk, high(int16), not int32(high(int16)), 32)
chkNot(chk, high(int32), not high(int32), 32)
chkNot(chk, "F0", "FFFFFF0F", 32)
chkNot(chk, "0F", "FFFFFFF0", 32)
chkNot(chk, "FF00", "FFFF00FF", 32)
chkNot(chk, "00FF", "FFFFFF00", 32)
chkNot(chk, "0000FFFF", "FFFF0000", 32)
chkNot(chk, "00FFFF00", "FF0000FF", 32)
chkNot(chk, "0F0F0F0F", "F0F0F0F0", 32)
chkNot(chk, 0'i8, not 0'i64, 64)
chkNot(chk, 0'i16, not 0'i64, 64)
chkNot(chk, 0'i32, not 0'i64, 64)
chkNot(chk, 0'i64, not 0'i64, 64)
chkNot(chk, high(int8), not int64(high(int8)), 64)
chkNot(chk, high(int16), not int64(high(int16)), 64)
chkNot(chk, high(int32), not int64(high(int32)), 64)
chkNot(chk, high(int64), not high(int64), 64)
chkNot(chk, "0", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 128)
chkNot(chk, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "0", 128)
chkNot(chk, "F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0", "0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F", 128)
chkNot(chk, "FFFFFFFFFFFF00000000000000000000", "000000000000FFFFFFFFFFFFFFFFFFFF", 128)
tst "operator `or`":
chkOr(chk, "00", "FF", "FF", 8)
chkOr(chk, "FF", "00", "FF", 8)
chkOr(chk, "F0", "0F", "FF", 8)
chkOr(chk, "00", "00", "00", 8)
chkOr(chk, "00", "FF", "00FF", 16)
chkOr(chk, "FF", "00", "00FF", 16)
chkOr(chk, "F0", "0F", "00FF", 16)
chkOr(chk, "00", "00", "0000", 16)
chkOr(chk, "FF00", "0F00", "FF00", 16)
chkOr(chk, "00", "FF", "000000FF", 32)
chkOr(chk, "FF", "00", "000000FF", 32)
chkOr(chk, "F0", "0F", "000000FF", 32)
chkOr(chk, "00", "00", "00000000", 32)
chkOr(chk, "FF00", "0F00", "0000FF00", 32)
chkOr(chk, "00FF00FF", "000F000F", "00FF00FF", 32)
chkOr(chk, "00", "FF", "00000000000000FF", 64)
chkOr(chk, "FF", "00", "00000000000000FF", 64)
chkOr(chk, "F0", "0F", "00000000000000FF", 64)
chkOr(chk, "00", "00", "0000000000000000", 64)
chkOr(chk, "FF00", "0F00", "000000000000FF00", 64)
chkOr(chk, "00FF00FF", "000F000F", "0000000000FF00FF", 64)
chkOr(chk, "00", "FF", "000000000000000000000000000000FF", 128)
chkOr(chk, "FF", "00", "000000000000000000000000000000FF", 128)
chkOr(chk, "F0", "0F", "000000000000000000000000000000FF", 128)
@ -125,33 +53,6 @@ template testBitwise(chk, tst: untyped) =
chkOr(chk, "00000000000000000000000000FF00FF", "FF0F0000000000000000000000FF00FF", "FF0F0000000000000000000000FF00FF", 128)
tst "operator `and`":
chkAnd(chk, "00", "FF", "00", 8)
chkAnd(chk, "FF", "00", "00", 8)
chkAnd(chk, "F0", "0F", "00", 8)
chkAnd(chk, "00", "00", "00", 8)
chkAnd(chk, "0F", "0F", "0F", 8)
chkAnd(chk, "FF", "FF", "FF", 8)
chkAnd(chk, "00", "FF", "0000", 16)
chkAnd(chk, "FF", "00", "0000", 16)
chkAnd(chk, "F0", "0F", "0000", 16)
chkAnd(chk, "00", "00", "0000", 16)
chkAnd(chk, "FF00", "0F00", "0F00", 16)
chkAnd(chk, "00", "FF", "00000000", 32)
chkAnd(chk, "FF", "00", "00000000", 32)
chkAnd(chk, "F0", "0F", "00000000", 32)
chkAnd(chk, "00", "00", "00000000", 32)
chkAnd(chk, "FF00", "0F00", "00000F00", 32)
chkAnd(chk, "00FF00FF", "000F000F", "000F000F", 32)
chkAnd(chk, "00", "FF", "0000000000000000", 64)
chkAnd(chk, "FF", "00", "0000000000000000", 64)
chkAnd(chk, "F0", "0F", "0000000000000000", 64)
chkAnd(chk, "00", "00", "0000000000000000", 64)
chkAnd(chk, "FF00", "0F00", "0000000000000F00", 64)
chkAnd(chk, "00FF00FF", "000F000F", "00000000000F000F", 64)
chkAnd(chk, "00", "FF", "00000000000000000000000000000000", 128)
chkAnd(chk, "FF", "00", "00000000000000000000000000000000", 128)
chkAnd(chk, "F0", "0F", "00000000000000000000000000000000", 128)
@ -161,33 +62,6 @@ template testBitwise(chk, tst: untyped) =
chkAnd(chk, "F0000000000000000000000000FF00FF", "FF0F0000000000000000000000FF00FF", "F0000000000000000000000000FF00FF", 128)
tst "operator `xor`":
chkXor(chk, "00", "FF", "FF", 8)
chkXor(chk, "FF", "00", "FF", 8)
chkXor(chk, "F0", "0F", "FF", 8)
chkXor(chk, "00", "00", "00", 8)
chkXor(chk, "0F", "0F", "00", 8)
chkXor(chk, "FF", "FF", "00", 8)
chkXor(chk, "00", "FF", "00FF", 16)
chkXor(chk, "FF", "00", "00FF", 16)
chkXor(chk, "F0", "0F", "00FF", 16)
chkXor(chk, "00", "00", "0000", 16)
chkXor(chk, "FF00", "0F00", "F000", 16)
chkXor(chk, "00", "FF", "000000FF", 32)
chkXor(chk, "FF", "00", "000000FF", 32)
chkXor(chk, "F0", "0F", "000000FF", 32)
chkXor(chk, "00", "00", "00000000", 32)
chkXor(chk, "FF00", "0F00", "0000F000", 32)
chkXor(chk, "00FF00FF", "000F000F", "00F000F0", 32)
chkXor(chk, "00", "FF", "00000000000000FF", 64)
chkXor(chk, "FF", "00", "00000000000000FF", 64)
chkXor(chk, "F0", "0F", "00000000000000FF", 64)
chkXor(chk, "00", "00", "0000000000000000", 64)
chkXor(chk, "FF00", "0F00", "000000000000F000", 64)
chkXor(chk, "00FF00FF", "000F000F", "0000000000F000F0", 64)
chkXor(chk, "00", "FF", "000000000000000000000000000000FF", 128)
chkXor(chk, "FF", "00", "000000000000000000000000000000FF", 128)
chkXor(chk, "F0", "0F", "000000000000000000000000000000FF", 128)
@ -197,37 +71,6 @@ template testBitwise(chk, tst: untyped) =
chkXor(chk, "F0000000000000000000000000FF00FF", "FF0F0000000000000000000000FF00FF", "0F0F0000000000000000000000000000", 128)
tst "operator `shl`":
chkShl(chk, "0F", 4, "F0", 8)
chkShl(chk, "F0", 4, "00", 8)
chkShl(chk, "F0", 3, "80", 8)
chkShl(chk, "0F", 7, "80", 8)
chkShl(chk, "0F", 4, "F0", 16)
chkShl(chk, "F0", 4, "F00", 16)
chkShl(chk, "F0", 3, "780", 16)
chkShl(chk, "F000", 3, "8000", 16)
chkShl(chk, "0F", 15, "8000", 16)
chkShl(chk, "0F", 4, "F0", 32)
chkShl(chk, "F0", 4, "F00", 32)
chkShl(chk, "F0", 3, "780", 32)
chkShl(chk, "F000", 3, "78000", 32)
chkShl(chk, "F0000000", 3, "80000000", 32)
chkShl(chk, "0F", 31, "80000000", 32)
chkShl(chk, "0F", 4, "F0", 64)
chkShl(chk, "F0", 4, "F00", 64)
chkShl(chk, "F0", 3, "780", 64)
chkShl(chk, "F000", 3, "78000", 64)
chkShl(chk, "F0000000", 3, "780000000", 64)
chkShl(chk, "F000000000000000", 3, "8000000000000000", 64)
chkShl(chk, "0F", 63, "8000000000000000", 64)
chkShl(chk, "0F", 5, "1E0", 64)
chkShl(chk, "0F", 9, "1E00", 64)
chkShl(chk, "0F", 17, "1E0000", 64)
chkShl(chk, "0F", 33, "1E00000000", 64)
chkShl(chk, "0F", 4, "F0", 128)
chkShl(chk, "F0", 4, "F00", 128)
chkShl(chk, "F0", 3, "780", 128)
@ -257,29 +100,6 @@ template testBitwise(chk, tst: untyped) =
chkShl(chk, "0F", 255, "8000000000000000000000000000000000000000000000000000000000000000", 256)
tst "operator `shr`":
chkShr(chk, "0F", 4, "00", 8)
chkShr(chk, "F0", 4, "FF", 8)
chkShr(chk, "F0", 3, "FE", 8)
chkShr(chk, "F0", 7, "FF", 8)
chkShr(chk, "0F", 4, "00", 16)
chkShr(chk, "F0", 4, "0F", 16)
chkShr(chk, "F000", 3, "FE00", 16)
chkShr(chk, "F000", 15, "FFFF", 16)
chkShr(chk, "0F", 4, "00", 32)
chkShr(chk, "F0", 4, "0F", 32)
chkShr(chk, "F0", 3, "1E", 32)
chkShr(chk, "F0000000", 3, "FE000000", 32)
chkShr(chk, "F0000000", 31, "FFFFFFFF", 32)
chkShr(chk, "0F", 4, "00", 64)
chkShr(chk, "F0", 4, "0F", 64)
chkShr(chk, "F0", 3, "1E", 64)
chkShr(chk, "F000", 3, "1E00", 64)
chkShr(chk, "F0000000", 3, "1E000000", 64)
chkShr(chk, "F000000000000000", 63, "FFFFFFFFFFFFFFFF", 64)
chkShr(chk, "0F", 4, "00", 128)
chkShr(chk, "F0", 4, "0F", 128)
chkShr(chk, "F0", 3, "1E", 128)