mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:07:36 +00:00
LibCrypto+LibJS: Better bigint bitwise_and binop
Bitwise and is defined in terms of two's complement, so some converting needs to happen for SignedBigInteger's sign/magnitude representation to work out. UnsignedBigInteger::bitwise_not() is repurposed to convert all high-order zero bits to ones up to a limit, for the two's complement conversion to work. Fixes test262/test/language/expressions/bitwise-and/bigint.js.
This commit is contained in:
parent
945d962322
commit
1f98639396
7 changed files with 52 additions and 23 deletions
|
@ -478,9 +478,11 @@ TEST_CASE(test_signed_bigint_bitwise_and)
|
|||
auto num1 = "-1234567"_sbigint;
|
||||
auto num2 = "1234567"_sbigint;
|
||||
EXPECT_EQ(num1.bitwise_and(num1), num1);
|
||||
EXPECT_EQ(num1.bitwise_and(num2), num2);
|
||||
EXPECT_EQ(num2.bitwise_and(num1), num2);
|
||||
EXPECT_EQ(num1.bitwise_and(num2), "1"_sbigint);
|
||||
EXPECT_EQ(num2.bitwise_and(num1), "1"_sbigint);
|
||||
EXPECT_EQ(num2.bitwise_and(num2), num2);
|
||||
|
||||
EXPECT_EQ("-3"_sbigint.bitwise_and("-2"_sbigint), "-4"_sbigint);
|
||||
}
|
||||
|
||||
TEST_CASE(test_bigint_bitwise_xor)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue