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:
Nico Weber 2022-01-17 19:54:02 -05:00 committed by Ali Mohammad Pur
commit 1f98639396
Notes: sideshowbarker 2024-07-17 20:40:16 +09:00
7 changed files with 52 additions and 23 deletions

View file

@ -218,11 +218,11 @@ FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_xor(const UnsignedBigInte
return result;
}
FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_not() const
FLATTEN UnsignedBigInteger UnsignedBigInteger::bitwise_not_fill_to_size(size_t size) const
{
UnsignedBigInteger result;
UnsignedBigIntegerAlgorithms::bitwise_not_without_allocation(*this, result);
UnsignedBigIntegerAlgorithms::bitwise_not_fill_to_size_without_allocation(*this, size, result);
return result;
}