1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

LibJS: Add all of the DataView.prototype.set* methods

This commit is contained in:
Idan Horowitz 2021-06-14 02:02:53 +03:00 committed by Linus Groh
parent c54b9a6920
commit d7a70eb77c
8 changed files with 203 additions and 0 deletions

View file

@ -55,6 +55,14 @@ String SignedBigInteger::to_base10() const
return builder.to_string();
}
u64 SignedBigInteger::to_u64() const
{
u64 unsigned_value = m_unsigned_data.to_u64();
if (!m_sign)
return unsigned_value;
return ~(unsigned_value - 1); // equivalent to `-unsigned_value`, but doesnt trigger UBSAN
}
FLATTEN SignedBigInteger SignedBigInteger::plus(const SignedBigInteger& other) const
{
// If both are of the same sign, just add the unsigned data and return.