feat: add aritmeticRight implementation

This commit is contained in:
Patrick 2025-04-15 09:38:24 +02:00
parent c875dd77fe
commit 19b469d1b3
No known key found for this signature in database
GPG key ID: 451F95EFB8BECD0F
3 changed files with 447 additions and 43 deletions

View file

@ -460,7 +460,9 @@ let
bit =
let
inherit (import ./shift.nix) left right;
inherit (import ./shift.nix) left arithmeticRight logicalRight;
leftOrArithRight = a: if a > 0 then left a else arithmeticRight (-a);
arithRightOrLeft = a: if a > 0 then arithmeticRight a else left (-a);
and = builtins.bitAnd;
or = builtins.bitOr;
@ -474,12 +476,15 @@ let
{
inherit
left
right
arithmeticRight
logicalRight
and
or
xor
not
mask
leftOrArithRight
arithRightOrLeft
;
};
@ -708,7 +713,7 @@ let
ipv4' = fmap (
address:
let
upper = bit.right 16 address.ipv4;
upper = bit.arithmeticRight 16 address.ipv4;
lower = bit.mask 16 address.ipv4;
in
[
@ -788,9 +793,9 @@ let
address:
let
abcd = address.ipv4;
abc = bit.right 8 abcd;
ab = bit.right 8 abc;
a = bit.right 8 ab;
abc = bit.arithmeticRight 8 abcd;
ab = bit.arithmeticRight 8 abc;
a = bit.arithmeticRight 8 ab;
b = bit.mask 8 ab;
c = bit.mask 8 abc;
d = bit.mask 8 abcd;
@ -815,7 +820,7 @@ let
toHexString =
n:
let
rest = bit.right 4 n;
rest = bit.arithmeticRight 4 n;
current = bit.mask 4 n;
prefix = if rest == 0 then "" else toHexString rest;
in
@ -829,13 +834,13 @@ let
else
let
a = bit.right 16 address.ipv6.a;
a = bit.arithmeticRight 16 address.ipv6.a;
b = bit.mask 16 address.ipv6.a;
c = bit.right 16 address.ipv6.b;
c = bit.arithmeticRight 16 address.ipv6.b;
d = bit.mask 16 address.ipv6.b;
e = bit.right 16 address.ipv6.c;
e = bit.arithmeticRight 16 address.ipv6.c;
f = bit.mask 16 address.ipv6.c;
g = bit.right 16 address.ipv6.d;
g = bit.arithmeticRight 16 address.ipv6.d;
h = bit.mask 16 address.ipv6.d;
hextets = [
@ -924,16 +929,16 @@ let
octet =
n:
let
upper = bit.right 4 n;
upper = bit.arithmeticRight 4 n;
lower = bit.mask 4 n;
in
"${builtins.substring upper 1 digits}${builtins.substring lower 1 digits}";
a = bit.mask 8 (bit.right 40 address.mac);
b = bit.mask 8 (bit.right 32 address.mac);
c = bit.mask 8 (bit.right 24 address.mac);
d = bit.mask 8 (bit.right 16 address.mac);
e = bit.mask 8 (bit.right 8 address.mac);
f = bit.mask 8 (bit.right 0 address.mac);
a = bit.mask 8 (bit.arithmeticRight 40 address.mac);
b = bit.mask 8 (bit.arithmeticRight 32 address.mac);
c = bit.mask 8 (bit.arithmeticRight 24 address.mac);
d = bit.mask 8 (bit.arithmeticRight 16 address.mac);
e = bit.mask 8 (bit.arithmeticRight 8 address.mac);
f = bit.mask 8 (bit.arithmeticRight 0 address.mac);
in
"${octet a}:${octet b}:${octet c}:${octet d}:${octet e}:${octet f}";
@ -1030,7 +1035,7 @@ let
add =
let
split = a: {
fst = bit.mask 32 (bit.right 32 a);
fst = bit.mask 32 (bit.arithmeticRight 32 a);
snd = bit.mask 32 a;
};
in
@ -1076,8 +1081,8 @@ let
max32 = bit.left 32 1 - 1;
in
if
result.a == 0 && result.b == 0 && bit.right 31 result.c == 0
|| result.a == max32 && result.b == max32 && bit.right 31 result.c == 1
result.a == 0 && result.b == 0 && bit.arithmeticRight 31 result.c == 0
|| result.a == max32 && result.b == max32 && bit.arithmeticRight 31 result.c == 1
then
bit.or (bit.left 32 result.c) result.d
else
@ -1092,13 +1097,13 @@ let
right =
let
step = i: x: {
_1 = bit.mask 32 (bit.right (i + 96) x);
_2 = bit.mask 32 (bit.right (i + 64) x);
_3 = bit.mask 32 (bit.right (i + 32) x);
_4 = bit.mask 32 (bit.right i x);
_5 = bit.mask 32 (bit.right (i - 32) x);
_6 = bit.mask 32 (bit.right (i - 64) x);
_7 = bit.mask 32 (bit.right (i - 96) x);
_1 = bit.mask 32 (bit.arithRightOrLeft (i + 96) x);
_2 = bit.mask 32 (bit.arithRightOrLeft (i + 64) x);
_3 = bit.mask 32 (bit.arithRightOrLeft (i + 32) x);
_4 = bit.mask 32 (bit.arithRightOrLeft i x);
_5 = bit.mask 32 (bit.arithRightOrLeft (i - 32) x);
_6 = bit.mask 32 (bit.arithRightOrLeft (i - 64) x);
_7 = bit.mask 32 (bit.arithRightOrLeft (i - 96) x);
};
ors = builtins.foldl' bit.or 0;
in
@ -1140,14 +1145,14 @@ let
}
else if x ? ipv4 then
{
ipv4 = bit.mask 32 (bit.right i x.ipv4);
ipv4 = bit.mask 32 (bit.arithRightOrLeft i x.ipv4);
}
else if x ? mac then
{
mac = bit.mask 48 (bit.right i x.mac);
mac = bit.mask 48 (bit.arithRightOrLeft i x.mac);
}
else
bit.right i x;
bit.arithRightOrLeft i x;
# shadow :: integer -> (ip | mac | integer) -> (ip | mac | integer)
shadow = n: a: and (right n (left n (coerce a (-1)))) a;
@ -1175,16 +1180,16 @@ let
ipv6 = {
a = 0;
b = 0;
c = bit.right 32 value.mac;
c = bit.arithmeticRight 32 value.mac;
d = bit.mask 32 value.mac;
};
}
else
{
ipv6 = {
a = bit.mask 32 (bit.right 96 value);
b = bit.mask 32 (bit.right 64 value);
c = bit.mask 32 (bit.right 32 value);
a = bit.mask 32 (bit.arithmeticRight 96 value);
b = bit.mask 32 (bit.arithmeticRight 64 value);
c = bit.mask 32 (bit.arithmeticRight 32 value);
d = bit.mask 32 value;
};
}
@ -1264,7 +1269,7 @@ let
size' = size cidr;
in
{
base = arithmetic.left size' (arithmetic.add delta (arithmetic.right size' cidr.base));
base = arithmetic.left size' (arithmetic.add delta (arithmetic.arithRightOrLeft size' cidr.base));
inherit (cidr) length;
};

View file

@ -75,7 +75,7 @@ let
else if a == 0 then
b
else if a < 0 then
right (-a) b
throw "Inverse Left Shift not supported"
else
let
inv = 63 - a;
@ -87,14 +87,14 @@ let
result = masked * mult;
in
if !negate then result else intmin + result;
right =
logicalRight =
a: b:
if a >= 64 then
0
else if a == 0 then
b
else if a < 0 then
left (-a) b
throw "Inverse right Shift not supported"
else
let
masked = builtins.bitAnd b intmax;
@ -106,7 +106,23 @@ let
highest_bit = builtins.elemAt lut inv;
in
if !negate then result else result + highest_bit;
arithmeticRight =
a: b:
if a >= 64 then
0
else if a == 0 then
b
else if a < 0 then
throw "Inverse right Shift not supported"
else
let
negate = b < 0;
mask = if a == 63 then intmax else (builtins.elemAt lut a) - 1;
round_down = negate && (builtins.bitAnd mask b != 0);
result = (b / 2 / (builtins.elemAt lut (a - 1)));
in
if round_down then result - 1 else result;
in
{
inherit left right;
inherit left logicalRight arithmeticRight;
}

View file

@ -5,11 +5,394 @@
}:
let
inherit (nixt.lib) block describe it;
inherit (pkgs.lib.bit) left;
inherit (pkgs.lib.bit) left logicalRight arithmeticRight;
in
block ./shift.nix [
(describe "" [
(it "Single left shift" (left 1 1 == 2))
(it "Single left shift" (left 1 2 == 2))
(it "left shift 31065 << 63" (left 63 31065 == -9223372036854775807 - 1))
(it "negative left shift 31065 << 63" (left 63 (-31065) == -9223372036854775807 - 1))
(it "logical right shift 31065 >> 63" (logicalRight 63 31065 == 0))
(it "negative logical right shift 31065 >> 63" (logicalRight 63 (-31065) == 1))
(it "arithmetic right shift 31065 >> 63" (arithmeticRight 63 31065 == 0))
(it "negative arithmetic right shift 31065 >> 63" (arithmeticRight 63 (-31065) == -1))
(it "left shift 25624 << 62" (left 62 25624 == 0))
(it "negative left shift 25624 << 62" (left 62 (-25624) == 0))
(it "logical right shift 25624 >> 62" (logicalRight 62 25624 == 0))
(it "negative logical right shift 25624 >> 62" (logicalRight 62 (-25624) == 3))
(it "arithmetic right shift 25624 >> 62" (arithmeticRight 62 25624 == 0))
(it "negative arithmetic right shift 25624 >> 62" (arithmeticRight 62 (-25624) == -1))
(it "left shift 308 << 61" (left 61 308 == -9223372036854775807 - 1))
(it "negative left shift 308 << 61" (left 61 (-308) == -9223372036854775807 - 1))
(it "logical right shift 308 >> 61" (logicalRight 61 308 == 0))
(it "negative logical right shift 308 >> 61" (logicalRight 61 (-308) == 7))
(it "arithmetic right shift 308 >> 61" (arithmeticRight 61 308 == 0))
(it "negative arithmetic right shift 308 >> 61" (arithmeticRight 61 (-308) == -1))
(it "left shift 16712 << 60" (left 60 16712 == -9223372036854775807 - 1))
(it "negative left shift 16712 << 60" (left 60 (-16712) == -9223372036854775807 - 1))
(it "logical right shift 16712 >> 60" (logicalRight 60 16712 == 0))
(it "negative logical right shift 16712 >> 60" (logicalRight 60 (-16712) == 15))
(it "arithmetic right shift 16712 >> 60" (arithmeticRight 60 16712 == 0))
(it "negative arithmetic right shift 16712 >> 60" (arithmeticRight 60 (-16712) == -1))
(it "left shift 5852 << 59" (left 59 5852 == -2305843009213693952))
(it "negative left shift 5852 << 59" (left 59 (-5852) == 2305843009213693952))
(it "logical right shift 5852 >> 59" (logicalRight 59 5852 == 0))
(it "negative logical right shift 5852 >> 59" (logicalRight 59 (-5852) == 31))
(it "arithmetic right shift 5852 >> 59" (arithmeticRight 59 5852 == 0))
(it "negative arithmetic right shift 5852 >> 59" (arithmeticRight 59 (-5852) == -1))
(it "left shift 389 << 58" (left 58 389 == 1441151880758558720))
(it "negative left shift 389 << 58" (left 58 (-389) == -1441151880758558720))
(it "logical right shift 389 >> 58" (logicalRight 58 389 == 0))
(it "negative logical right shift 389 >> 58" (logicalRight 58 (-389) == 63))
(it "arithmetic right shift 389 >> 58" (arithmeticRight 58 389 == 0))
(it "negative arithmetic right shift 389 >> 58" (arithmeticRight 58 (-389) == -1))
(it "left shift 13663 << 57" (left 57 13663 == -4755801206503243776))
(it "negative left shift 13663 << 57" (left 57 (-13663) == 4755801206503243776))
(it "logical right shift 13663 >> 57" (logicalRight 57 13663 == 0))
(it "negative logical right shift 13663 >> 57" (logicalRight 57 (-13663) == 127))
(it "arithmetic right shift 13663 >> 57" (arithmeticRight 57 13663 == 0))
(it "negative arithmetic right shift 13663 >> 57" (arithmeticRight 57 (-13663) == -1))
(it "left shift 15349 << 56" (left 56 15349 == -792633534417207296))
(it "negative left shift 15349 << 56" (left 56 (-15349) == 792633534417207296))
(it "logical right shift 15349 >> 56" (logicalRight 56 15349 == 0))
(it "negative logical right shift 15349 >> 56" (logicalRight 56 (-15349) == 255))
(it "arithmetic right shift 15349 >> 56" (arithmeticRight 56 15349 == 0))
(it "negative arithmetic right shift 15349 >> 56" (arithmeticRight 56 (-15349) == -1))
(it "left shift 25817 << 55" (left 55 25817 == 7818248953115181056))
(it "negative left shift 25817 << 55" (left 55 (-25817) == -7818248953115181056))
(it "logical right shift 25817 >> 55" (logicalRight 55 25817 == 0))
(it "negative logical right shift 25817 >> 55" (logicalRight 55 (-25817) == 511))
(it "arithmetic right shift 25817 >> 55" (arithmeticRight 55 25817 == 0))
(it "negative arithmetic right shift 25817 >> 55" (arithmeticRight 55 (-25817) == -1))
(it "left shift 896 << 54" (left 54 896 == -2305843009213693952))
(it "negative left shift 896 << 54" (left 54 (-896) == 2305843009213693952))
(it "logical right shift 896 >> 54" (logicalRight 54 896 == 0))
(it "negative logical right shift 896 >> 54" (logicalRight 54 (-896) == 1023))
(it "arithmetic right shift 896 >> 54" (arithmeticRight 54 896 == 0))
(it "negative arithmetic right shift 896 >> 54" (arithmeticRight 54 (-896) == -1))
(it "left shift 14592 << 53" (left 53 14592 == 2305843009213693952))
(it "negative left shift 14592 << 53" (left 53 (-14592) == -2305843009213693952))
(it "logical right shift 14592 >> 53" (logicalRight 53 14592 == 0))
(it "negative logical right shift 14592 >> 53" (logicalRight 53 (-14592) == 2047))
(it "arithmetic right shift 14592 >> 53" (arithmeticRight 53 14592 == 0))
(it "negative arithmetic right shift 14592 >> 53" (arithmeticRight 53 (-14592) == -1))
(it "left shift 8533 << 52" (left 52 8533 == 1535727472933339136))
(it "negative left shift 8533 << 52" (left 52 (-8533) == -1535727472933339136))
(it "logical right shift 8533 >> 52" (logicalRight 52 8533 == 0))
(it "negative logical right shift 8533 >> 52" (logicalRight 52 (-8533) == 4095))
(it "arithmetic right shift 8533 >> 52" (arithmeticRight 52 8533 == 0))
(it "negative arithmetic right shift 8533 >> 52" (arithmeticRight 52 (-8533) == -1))
(it "left shift 30180 << 51" (left 51 30180 == -5827657917817421824))
(it "negative left shift 30180 << 51" (left 51 (-30180) == 5827657917817421824))
(it "logical right shift 30180 >> 51" (logicalRight 51 30180 == 0))
(it "negative logical right shift 30180 >> 51" (logicalRight 51 (-30180) == 8191))
(it "arithmetic right shift 30180 >> 51" (arithmeticRight 51 30180 == 0))
(it "negative arithmetic right shift 30180 >> 51" (arithmeticRight 51 (-30180) == -1))
(it "left shift 24903 << 50" (left 50 24903 == -8855202767317237760))
(it "negative left shift 24903 << 50" (left 50 (-24903) == 8855202767317237760))
(it "logical right shift 24903 >> 50" (logicalRight 50 24903 == 0))
(it "negative logical right shift 24903 >> 50" (logicalRight 50 (-24903) == 16383))
(it "arithmetic right shift 24903 >> 50" (arithmeticRight 50 24903 == 0))
(it "negative arithmetic right shift 24903 >> 50" (arithmeticRight 50 (-24903) == -1))
(it "left shift 14440 << 49" (left 49 14440 == 8128997327403745280))
(it "negative left shift 14440 << 49" (left 49 (-14440) == -8128997327403745280))
(it "logical right shift 14440 >> 49" (logicalRight 49 14440 == 0))
(it "negative logical right shift 14440 >> 49" (logicalRight 49 (-14440) == 32767))
(it "arithmetic right shift 14440 >> 49" (arithmeticRight 49 14440 == 0))
(it "negative arithmetic right shift 14440 >> 49" (arithmeticRight 49 (-14440) == -1))
(it "left shift 7398 << 48" (left 48 7398 == 2082351877705433088))
(it "negative left shift 7398 << 48" (left 48 (-7398) == -2082351877705433088))
(it "logical right shift 7398 >> 48" (logicalRight 48 7398 == 0))
(it "negative logical right shift 7398 >> 48" (logicalRight 48 (-7398) == 65535))
(it "arithmetic right shift 7398 >> 48" (arithmeticRight 48 7398 == 0))
(it "negative arithmetic right shift 7398 >> 48" (arithmeticRight 48 (-7398) == -1))
(it "left shift 10215 << 47" (left 47 10215 == 1437633443549675520))
(it "negative left shift 10215 << 47" (left 47 (-10215) == -1437633443549675520))
(it "logical right shift 10215 >> 47" (logicalRight 47 10215 == 0))
(it "negative logical right shift 10215 >> 47" (logicalRight 47 (-10215) == 131071))
(it "arithmetic right shift 10215 >> 47" (arithmeticRight 47 10215 == 0))
(it "negative arithmetic right shift 10215 >> 47" (arithmeticRight 47 (-10215) == -1))
(it "left shift 10172 << 46" (left 46 10172 == 715790865775198208))
(it "negative left shift 10172 << 46" (left 46 (-10172) == -715790865775198208))
(it "logical right shift 10172 >> 46" (logicalRight 46 10172 == 0))
(it "negative logical right shift 10172 >> 46" (logicalRight 46 (-10172) == 262143))
(it "arithmetic right shift 10172 >> 46" (arithmeticRight 46 10172 == 0))
(it "negative arithmetic right shift 10172 >> 46" (arithmeticRight 46 (-10172) == -1))
(it "left shift 15671 << 45" (left 45 15671 == 551374295004086272))
(it "negative left shift 15671 << 45" (left 45 (-15671) == -551374295004086272))
(it "logical right shift 15671 >> 45" (logicalRight 45 15671 == 0))
(it "negative logical right shift 15671 >> 45" (logicalRight 45 (-15671) == 524287))
(it "arithmetic right shift 15671 >> 45" (arithmeticRight 45 15671 == 0))
(it "negative arithmetic right shift 15671 >> 45" (arithmeticRight 45 (-15671) == -1))
(it "left shift 22286 << 44" (left 44 22286 == 392059458185854976))
(it "negative left shift 22286 << 44" (left 44 (-22286) == -392059458185854976))
(it "logical right shift 22286 >> 44" (logicalRight 44 22286 == 0))
(it "negative logical right shift 22286 >> 44" (logicalRight 44 (-22286) == 1048575))
(it "arithmetic right shift 22286 >> 44" (arithmeticRight 44 22286 == 0))
(it "negative arithmetic right shift 22286 >> 44" (arithmeticRight 44 (-22286) == -1))
(it "left shift 29742 << 43" (left 43 29742 == 261613398666510336))
(it "negative left shift 29742 << 43" (left 43 (-29742) == -261613398666510336))
(it "logical right shift 29742 >> 43" (logicalRight 43 29742 == 0))
(it "negative logical right shift 29742 >> 43" (logicalRight 43 (-29742) == 2097151))
(it "arithmetic right shift 29742 >> 43" (arithmeticRight 43 29742 == 0))
(it "negative arithmetic right shift 29742 >> 43" (arithmeticRight 43 (-29742) == -1))
(it "left shift 13223 << 42" (left 42 13223 == 58155369016328192))
(it "negative left shift 13223 << 42" (left 42 (-13223) == -58155369016328192))
(it "logical right shift 13223 >> 42" (logicalRight 42 13223 == 0))
(it "negative logical right shift 13223 >> 42" (logicalRight 42 (-13223) == 4194303))
(it "arithmetic right shift 13223 >> 42" (arithmeticRight 42 13223 == 0))
(it "negative arithmetic right shift 13223 >> 42" (arithmeticRight 42 (-13223) == -1))
(it "left shift 27362 << 41" (left 41 27362 == 60169674318413824))
(it "negative left shift 27362 << 41" (left 41 (-27362) == -60169674318413824))
(it "logical right shift 27362 >> 41" (logicalRight 41 27362 == 0))
(it "negative logical right shift 27362 >> 41" (logicalRight 41 (-27362) == 8388607))
(it "arithmetic right shift 27362 >> 41" (arithmeticRight 41 27362 == 0))
(it "negative arithmetic right shift 27362 >> 41" (arithmeticRight 41 (-27362) == -1))
(it "left shift 9358 << 40" (left 40 9358 == 10289229812727808))
(it "negative left shift 9358 << 40" (left 40 (-9358) == -10289229812727808))
(it "logical right shift 9358 >> 40" (logicalRight 40 9358 == 0))
(it "negative logical right shift 9358 >> 40" (logicalRight 40 (-9358) == 16777215))
(it "arithmetic right shift 9358 >> 40" (arithmeticRight 40 9358 == 0))
(it "negative arithmetic right shift 9358 >> 40" (arithmeticRight 40 (-9358) == -1))
(it "left shift 11691 << 39" (left 39 11691 == 6427195220164608))
(it "negative left shift 11691 << 39" (left 39 (-11691) == -6427195220164608))
(it "logical right shift 11691 >> 39" (logicalRight 39 11691 == 0))
(it "negative logical right shift 11691 >> 39" (logicalRight 39 (-11691) == 33554431))
(it "arithmetic right shift 11691 >> 39" (arithmeticRight 39 11691 == 0))
(it "negative arithmetic right shift 11691 >> 39" (arithmeticRight 39 (-11691) == -1))
(it "left shift 18608 << 38" (left 38 18608 == 5114928092413952))
(it "negative left shift 18608 << 38" (left 38 (-18608) == -5114928092413952))
(it "logical right shift 18608 >> 38" (logicalRight 38 18608 == 0))
(it "negative logical right shift 18608 >> 38" (logicalRight 38 (-18608) == 67108863))
(it "arithmetic right shift 18608 >> 38" (arithmeticRight 38 18608 == 0))
(it "negative arithmetic right shift 18608 >> 38" (arithmeticRight 38 (-18608) == -1))
(it "left shift 30802 << 37" (left 37 30802 == 4233394644844544))
(it "negative left shift 30802 << 37" (left 37 (-30802) == -4233394644844544))
(it "logical right shift 30802 >> 37" (logicalRight 37 30802 == 0))
(it "negative logical right shift 30802 >> 37" (logicalRight 37 (-30802) == 134217727))
(it "arithmetic right shift 30802 >> 37" (arithmeticRight 37 30802 == 0))
(it "negative arithmetic right shift 30802 >> 37" (arithmeticRight 37 (-30802) == -1))
(it "left shift 25321 << 36" (left 36 25321 == 1740045870432256))
(it "negative left shift 25321 << 36" (left 36 (-25321) == -1740045870432256))
(it "logical right shift 25321 >> 36" (logicalRight 36 25321 == 0))
(it "negative logical right shift 25321 >> 36" (logicalRight 36 (-25321) == 268435455))
(it "arithmetic right shift 25321 >> 36" (arithmeticRight 36 25321 == 0))
(it "negative arithmetic right shift 25321 >> 36" (arithmeticRight 36 (-25321) == -1))
(it "left shift 21777 << 35" (left 35 21777 == 748252022439936))
(it "negative left shift 21777 << 35" (left 35 (-21777) == -748252022439936))
(it "logical right shift 21777 >> 35" (logicalRight 35 21777 == 0))
(it "negative logical right shift 21777 >> 35" (logicalRight 35 (-21777) == 536870911))
(it "arithmetic right shift 21777 >> 35" (arithmeticRight 35 21777 == 0))
(it "negative arithmetic right shift 21777 >> 35" (arithmeticRight 35 (-21777) == -1))
(it "left shift 19037 << 34" (left 34 19037 == 327053169655808))
(it "negative left shift 19037 << 34" (left 34 (-19037) == -327053169655808))
(it "logical right shift 19037 >> 34" (logicalRight 34 19037 == 0))
(it "negative logical right shift 19037 >> 34" (logicalRight 34 (-19037) == 1073741823))
(it "arithmetic right shift 19037 >> 34" (arithmeticRight 34 19037 == 0))
(it "negative arithmetic right shift 19037 >> 34" (arithmeticRight 34 (-19037) == -1))
(it "left shift 23041 << 33" (left 33 23041 == 197920682934272))
(it "negative left shift 23041 << 33" (left 33 (-23041) == -197920682934272))
(it "logical right shift 23041 >> 33" (logicalRight 33 23041 == 0))
(it "negative logical right shift 23041 >> 33" (logicalRight 33 (-23041) == 2147483647))
(it "arithmetic right shift 23041 >> 33" (arithmeticRight 33 23041 == 0))
(it "negative arithmetic right shift 23041 >> 33" (arithmeticRight 33 (-23041) == -1))
(it "left shift 13483 << 32" (left 32 13483 == 57909044051968))
(it "negative left shift 13483 << 32" (left 32 (-13483) == -57909044051968))
(it "logical right shift 13483 >> 32" (logicalRight 32 13483 == 0))
(it "negative logical right shift 13483 >> 32" (logicalRight 32 (-13483) == 4294967295))
(it "arithmetic right shift 13483 >> 32" (arithmeticRight 32 13483 == 0))
(it "negative arithmetic right shift 13483 >> 32" (arithmeticRight 32 (-13483) == -1))
(it "left shift 12790 << 31" (left 31 12790 == 27466315857920))
(it "negative left shift 12790 << 31" (left 31 (-12790) == -27466315857920))
(it "logical right shift 12790 >> 31" (logicalRight 31 12790 == 0))
(it "negative logical right shift 12790 >> 31" (logicalRight 31 (-12790) == 8589934591))
(it "arithmetic right shift 12790 >> 31" (arithmeticRight 31 12790 == 0))
(it "negative arithmetic right shift 12790 >> 31" (arithmeticRight 31 (-12790) == -1))
(it "left shift 29648 << 30" (left 30 29648 == 31834297597952))
(it "negative left shift 29648 << 30" (left 30 (-29648) == -31834297597952))
(it "logical right shift 29648 >> 30" (logicalRight 30 29648 == 0))
(it "negative logical right shift 29648 >> 30" (logicalRight 30 (-29648) == 17179869183))
(it "arithmetic right shift 29648 >> 30" (arithmeticRight 30 29648 == 0))
(it "negative arithmetic right shift 29648 >> 30" (arithmeticRight 30 (-29648) == -1))
(it "left shift 31723 << 29" (left 29 31723 == 17031155941376))
(it "negative left shift 31723 << 29" (left 29 (-31723) == -17031155941376))
(it "logical right shift 31723 >> 29" (logicalRight 29 31723 == 0))
(it "negative logical right shift 31723 >> 29" (logicalRight 29 (-31723) == 34359738367))
(it "arithmetic right shift 31723 >> 29" (arithmeticRight 29 31723 == 0))
(it "negative arithmetic right shift 31723 >> 29" (arithmeticRight 29 (-31723) == -1))
(it "left shift 429 << 28" (left 28 429 == 115158810624))
(it "negative left shift 429 << 28" (left 28 (-429) == -115158810624))
(it "logical right shift 429 >> 28" (logicalRight 28 429 == 0))
(it "negative logical right shift 429 >> 28" (logicalRight 28 (-429) == 68719476735))
(it "arithmetic right shift 429 >> 28" (arithmeticRight 28 429 == 0))
(it "negative arithmetic right shift 429 >> 28" (arithmeticRight 28 (-429) == -1))
(it "left shift 3138 << 27" (left 27 3138 == 421175230464))
(it "negative left shift 3138 << 27" (left 27 (-3138) == -421175230464))
(it "logical right shift 3138 >> 27" (logicalRight 27 3138 == 0))
(it "negative logical right shift 3138 >> 27" (logicalRight 27 (-3138) == 137438953471))
(it "arithmetic right shift 3138 >> 27" (arithmeticRight 27 3138 == 0))
(it "negative arithmetic right shift 3138 >> 27" (arithmeticRight 27 (-3138) == -1))
(it "left shift 20136 << 26" (left 26 20136 == 1351304085504))
(it "negative left shift 20136 << 26" (left 26 (-20136) == -1351304085504))
(it "logical right shift 20136 >> 26" (logicalRight 26 20136 == 0))
(it "negative logical right shift 20136 >> 26" (logicalRight 26 (-20136) == 274877906943))
(it "arithmetic right shift 20136 >> 26" (arithmeticRight 26 20136 == 0))
(it "negative arithmetic right shift 20136 >> 26" (arithmeticRight 26 (-20136) == -1))
(it "left shift 27841 << 25" (left 25 27841 == 934188941312))
(it "negative left shift 27841 << 25" (left 25 (-27841) == -934188941312))
(it "logical right shift 27841 >> 25" (logicalRight 25 27841 == 0))
(it "negative logical right shift 27841 >> 25" (logicalRight 25 (-27841) == 549755813887))
(it "arithmetic right shift 27841 >> 25" (arithmeticRight 25 27841 == 0))
(it "negative arithmetic right shift 27841 >> 25" (arithmeticRight 25 (-27841) == -1))
(it "left shift 23965 << 24" (left 24 23965 == 402065981440))
(it "negative left shift 23965 << 24" (left 24 (-23965) == -402065981440))
(it "logical right shift 23965 >> 24" (logicalRight 24 23965 == 0))
(it "negative logical right shift 23965 >> 24" (logicalRight 24 (-23965) == 1099511627775))
(it "arithmetic right shift 23965 >> 24" (arithmeticRight 24 23965 == 0))
(it "negative arithmetic right shift 23965 >> 24" (arithmeticRight 24 (-23965) == -1))
(it "left shift 9647 << 23" (left 23 9647 == 80924901376))
(it "negative left shift 9647 << 23" (left 23 (-9647) == -80924901376))
(it "logical right shift 9647 >> 23" (logicalRight 23 9647 == 0))
(it "negative logical right shift 9647 >> 23" (logicalRight 23 (-9647) == 2199023255551))
(it "arithmetic right shift 9647 >> 23" (arithmeticRight 23 9647 == 0))
(it "negative arithmetic right shift 9647 >> 23" (arithmeticRight 23 (-9647) == -1))
(it "left shift 13329 << 22" (left 22 13329 == 55905878016))
(it "negative left shift 13329 << 22" (left 22 (-13329) == -55905878016))
(it "logical right shift 13329 >> 22" (logicalRight 22 13329 == 0))
(it "negative logical right shift 13329 >> 22" (logicalRight 22 (-13329) == 4398046511103))
(it "arithmetic right shift 13329 >> 22" (arithmeticRight 22 13329 == 0))
(it "negative arithmetic right shift 13329 >> 22" (arithmeticRight 22 (-13329) == -1))
(it "left shift 32694 << 21" (left 21 32694 == 68564287488))
(it "negative left shift 32694 << 21" (left 21 (-32694) == -68564287488))
(it "logical right shift 32694 >> 21" (logicalRight 21 32694 == 0))
(it "negative logical right shift 32694 >> 21" (logicalRight 21 (-32694) == 8796093022207))
(it "arithmetic right shift 32694 >> 21" (arithmeticRight 21 32694 == 0))
(it "negative arithmetic right shift 32694 >> 21" (arithmeticRight 21 (-32694) == -1))
(it "left shift 17805 << 20" (left 20 17805 == 18669895680))
(it "negative left shift 17805 << 20" (left 20 (-17805) == -18669895680))
(it "logical right shift 17805 >> 20" (logicalRight 20 17805 == 0))
(it "negative logical right shift 17805 >> 20" (logicalRight 20 (-17805) == 17592186044415))
(it "arithmetic right shift 17805 >> 20" (arithmeticRight 20 17805 == 0))
(it "negative arithmetic right shift 17805 >> 20" (arithmeticRight 20 (-17805) == -1))
(it "left shift 32292 << 19" (left 19 32292 == 16930308096))
(it "negative left shift 32292 << 19" (left 19 (-32292) == -16930308096))
(it "logical right shift 32292 >> 19" (logicalRight 19 32292 == 0))
(it "negative logical right shift 32292 >> 19" (logicalRight 19 (-32292) == 35184372088831))
(it "arithmetic right shift 32292 >> 19" (arithmeticRight 19 32292 == 0))
(it "negative arithmetic right shift 32292 >> 19" (arithmeticRight 19 (-32292) == -1))
(it "left shift 16841 << 18" (left 18 16841 == 4414767104))
(it "negative left shift 16841 << 18" (left 18 (-16841) == -4414767104))
(it "logical right shift 16841 >> 18" (logicalRight 18 16841 == 0))
(it "negative logical right shift 16841 >> 18" (logicalRight 18 (-16841) == 70368744177663))
(it "arithmetic right shift 16841 >> 18" (arithmeticRight 18 16841 == 0))
(it "negative arithmetic right shift 16841 >> 18" (arithmeticRight 18 (-16841) == -1))
(it "left shift 18798 << 17" (left 17 18798 == 2463891456))
(it "negative left shift 18798 << 17" (left 17 (-18798) == -2463891456))
(it "logical right shift 18798 >> 17" (logicalRight 17 18798 == 0))
(it "negative logical right shift 18798 >> 17" (logicalRight 17 (-18798) == 140737488355327))
(it "arithmetic right shift 18798 >> 17" (arithmeticRight 17 18798 == 0))
(it "negative arithmetic right shift 18798 >> 17" (arithmeticRight 17 (-18798) == -1))
(it "left shift 2511 << 16" (left 16 2511 == 164560896))
(it "negative left shift 2511 << 16" (left 16 (-2511) == -164560896))
(it "logical right shift 2511 >> 16" (logicalRight 16 2511 == 0))
(it "negative logical right shift 2511 >> 16" (logicalRight 16 (-2511) == 281474976710655))
(it "arithmetic right shift 2511 >> 16" (arithmeticRight 16 2511 == 0))
(it "negative arithmetic right shift 2511 >> 16" (arithmeticRight 16 (-2511) == -1))
(it "left shift 933 << 15" (left 15 933 == 30572544))
(it "negative left shift 933 << 15" (left 15 (-933) == -30572544))
(it "logical right shift 933 >> 15" (logicalRight 15 933 == 0))
(it "negative logical right shift 933 >> 15" (logicalRight 15 (-933) == 562949953421311))
(it "arithmetic right shift 933 >> 15" (arithmeticRight 15 933 == 0))
(it "negative arithmetic right shift 933 >> 15" (arithmeticRight 15 (-933) == -1))
(it "left shift 26861 << 14" (left 14 26861 == 440090624))
(it "negative left shift 26861 << 14" (left 14 (-26861) == -440090624))
(it "logical right shift 26861 >> 14" (logicalRight 14 26861 == 1))
(it "negative logical right shift 26861 >> 14" (logicalRight 14 (-26861) == 1125899906842622))
(it "arithmetic right shift 26861 >> 14" (arithmeticRight 14 26861 == 1))
(it "negative arithmetic right shift 26861 >> 14" (arithmeticRight 14 (-26861) == -2))
(it "left shift 13766 << 13" (left 13 13766 == 112771072))
(it "negative left shift 13766 << 13" (left 13 (-13766) == -112771072))
(it "logical right shift 13766 >> 13" (logicalRight 13 13766 == 1))
(it "negative logical right shift 13766 >> 13" (logicalRight 13 (-13766) == 2251799813685246))
(it "arithmetic right shift 13766 >> 13" (arithmeticRight 13 13766 == 1))
(it "negative arithmetic right shift 13766 >> 13" (arithmeticRight 13 (-13766) == -2))
(it "left shift 21344 << 12" (left 12 21344 == 87425024))
(it "negative left shift 21344 << 12" (left 12 (-21344) == -87425024))
(it "logical right shift 21344 >> 12" (logicalRight 12 21344 == 5))
(it "negative logical right shift 21344 >> 12" (logicalRight 12 (-21344) == 4503599627370490))
(it "arithmetic right shift 21344 >> 12" (arithmeticRight 12 21344 == 5))
(it "negative arithmetic right shift 21344 >> 12" (arithmeticRight 12 (-21344) == -6))
(it "left shift 8246 << 11" (left 11 8246 == 16887808))
(it "negative left shift 8246 << 11" (left 11 (-8246) == -16887808))
(it "logical right shift 8246 >> 11" (logicalRight 11 8246 == 4))
(it "negative logical right shift 8246 >> 11" (logicalRight 11 (-8246) == 9007199254740987))
(it "arithmetic right shift 8246 >> 11" (arithmeticRight 11 8246 == 4))
(it "negative arithmetic right shift 8246 >> 11" (arithmeticRight 11 (-8246) == -5))
(it "left shift 18044 << 10" (left 10 18044 == 18477056))
(it "negative left shift 18044 << 10" (left 10 (-18044) == -18477056))
(it "logical right shift 18044 >> 10" (logicalRight 10 18044 == 17))
(it "negative logical right shift 18044 >> 10" (logicalRight 10 (-18044) == 18014398509481966))
(it "arithmetic right shift 18044 >> 10" (arithmeticRight 10 18044 == 17))
(it "negative arithmetic right shift 18044 >> 10" (arithmeticRight 10 (-18044) == -18))
(it "left shift 11554 << 9" (left 9 11554 == 5915648))
(it "negative left shift 11554 << 9" (left 9 (-11554) == -5915648))
(it "logical right shift 11554 >> 9" (logicalRight 9 11554 == 22))
(it "negative logical right shift 11554 >> 9" (logicalRight 9 (-11554) == 36028797018963945))
(it "arithmetic right shift 11554 >> 9" (arithmeticRight 9 11554 == 22))
(it "negative arithmetic right shift 11554 >> 9" (arithmeticRight 9 (-11554) == -23))
(it "left shift 19651 << 8" (left 8 19651 == 5030656))
(it "negative left shift 19651 << 8" (left 8 (-19651) == -5030656))
(it "logical right shift 19651 >> 8" (logicalRight 8 19651 == 76))
(it "negative logical right shift 19651 >> 8" (logicalRight 8 (-19651) == 72057594037927859))
(it "arithmetic right shift 19651 >> 8" (arithmeticRight 8 19651 == 76))
(it "negative arithmetic right shift 19651 >> 8" (arithmeticRight 8 (-19651) == -77))
(it "left shift 32588 << 7" (left 7 32588 == 4171264))
(it "negative left shift 32588 << 7" (left 7 (-32588) == -4171264))
(it "logical right shift 32588 >> 7" (logicalRight 7 32588 == 254))
(it "negative logical right shift 32588 >> 7" (logicalRight 7 (-32588) == 144115188075855617))
(it "arithmetic right shift 32588 >> 7" (arithmeticRight 7 32588 == 254))
(it "negative arithmetic right shift 32588 >> 7" (arithmeticRight 7 (-32588) == -255))
(it "left shift 23333 << 6" (left 6 23333 == 1493312))
(it "negative left shift 23333 << 6" (left 6 (-23333) == -1493312))
(it "logical right shift 23333 >> 6" (logicalRight 6 23333 == 364))
(it "negative logical right shift 23333 >> 6" (logicalRight 6 (-23333) == 288230376151711379))
(it "arithmetic right shift 23333 >> 6" (arithmeticRight 6 23333 == 364))
(it "negative arithmetic right shift 23333 >> 6" (arithmeticRight 6 (-23333) == -365))
(it "left shift 13058 << 5" (left 5 13058 == 417856))
(it "negative left shift 13058 << 5" (left 5 (-13058) == -417856))
(it "logical right shift 13058 >> 5" (logicalRight 5 13058 == 408))
(it "negative logical right shift 13058 >> 5" (logicalRight 5 (-13058) == 576460752303423079))
(it "arithmetic right shift 13058 >> 5" (arithmeticRight 5 13058 == 408))
(it "negative arithmetic right shift 13058 >> 5" (arithmeticRight 5 (-13058) == -409))
(it "left shift 10754 << 4" (left 4 10754 == 172064))
(it "negative left shift 10754 << 4" (left 4 (-10754) == -172064))
(it "logical right shift 10754 >> 4" (logicalRight 4 10754 == 672))
(it "negative logical right shift 10754 >> 4" (logicalRight 4 (-10754) == 1152921504606846303))
(it "arithmetic right shift 10754 >> 4" (arithmeticRight 4 10754 == 672))
(it "negative arithmetic right shift 10754 >> 4" (arithmeticRight 4 (-10754) == -673))
(it "left shift 22538 << 3" (left 3 22538 == 180304))
(it "negative left shift 22538 << 3" (left 3 (-22538) == -180304))
(it "logical right shift 22538 >> 3" (logicalRight 3 22538 == 2817))
(it "negative logical right shift 22538 >> 3" (logicalRight 3 (-22538) == 2305843009213691134))
(it "arithmetic right shift 22538 >> 3" (arithmeticRight 3 22538 == 2817))
(it "negative arithmetic right shift 22538 >> 3" (arithmeticRight 3 (-22538) == -2818))
(it "left shift 1792 << 2" (left 2 1792 == 7168))
(it "negative left shift 1792 << 2" (left 2 (-1792) == -7168))
(it "logical right shift 1792 >> 2" (logicalRight 2 1792 == 448))
(it "negative logical right shift 1792 >> 2" (logicalRight 2 (-1792) == 4611686018427387456))
(it "arithmetic right shift 1792 >> 2" (arithmeticRight 2 1792 == 448))
(it "negative arithmetic right shift 1792 >> 2" (arithmeticRight 2 (-1792) == -448))
(it "left shift 29700 << 1" (left 1 29700 == 59400))
(it "negative left shift 29700 << 1" (left 1 (-29700) == -59400))
(it "logical right shift 29700 >> 1" (logicalRight 1 29700 == 14850))
(it "negative logical right shift 29700 >> 1" (logicalRight 1 (-29700) == 9223372036854760958))
(it "arithmetic right shift 29700 >> 1" (arithmeticRight 1 29700 == 14850))
(it "negative arithmetic right shift 29700 >> 1" (arithmeticRight 1 (-29700) == -14850))
(it "left shift 21068 << 0" (left 0 21068 == 21068))
(it "negative left shift 21068 << 0" (left 0 (-21068) == -21068))
(it "logical right shift 21068 >> 0" (logicalRight 0 21068 == 21068))
(it "negative logical right shift 21068 >> 0" (logicalRight 0 (-21068) == -21068))
(it "arithmetic right shift 21068 >> 0" (arithmeticRight 0 21068 == 21068))
(it "negative arithmetic right shift 21068 >> 0" (arithmeticRight 0 (-21068) == -21068))
])
]