mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibCrypto+LibJS: Better bitwise binary_xor binop
We went through some trouble to make & and | work right. Reimplement ^ in terms of & and | to make ^ work right as well. This is less fast than a direct implementation, but let's get things working first.
This commit is contained in:
parent
013799a4dd
commit
d9b6eb29bc
2 changed files with 3 additions and 8 deletions
|
@ -238,12 +238,7 @@ FLATTEN SignedBigInteger SignedBigInteger::bitwise_and(const SignedBigInteger& o
|
|||
|
||||
FLATTEN SignedBigInteger SignedBigInteger::bitwise_xor(const SignedBigInteger& other) const
|
||||
{
|
||||
auto result = bitwise_xor(other.unsigned_value());
|
||||
|
||||
// The sign bit will have to be XOR'd manually.
|
||||
result.m_sign = is_negative() ^ other.is_negative();
|
||||
|
||||
return result;
|
||||
return bitwise_or(other).minus(bitwise_and(other));
|
||||
}
|
||||
|
||||
bool SignedBigInteger::operator==(const UnsignedBigInteger& other) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue