summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
diff options
context:
space:
mode:
authorMoustafa Raafat <MoustafaRaafat2@gmail.com>2022-10-23 16:46:35 +0100
committerAndrew Kaster <andrewdkaster@gmail.com>2022-11-02 22:04:34 -0600
commit54b8a2b094c1f8ec94acedcc89d314a7b90f572f (patch)
treecf2f1bc7d6ed6c31426280dee112e254ba24f536 /Userland/Libraries/LibJS/Runtime
parente03f014e7ac4ea99b2b6b42164cb6ffd7d8c4c9d (diff)
downloadserenity-54b8a2b094c1f8ec94acedcc89d314a7b90f572f.zip
LibCrypto: Add a way to compare UnsignedBigInteger with double
This patch also make SignedBigInteger::compare_to_double make use of the new function.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp
index 7d84ba0c32..f93ee686d3 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp
@@ -557,7 +557,7 @@ ThrowCompletionOr<NanosecondsToDaysResult> nanoseconds_to_days(VM& vm, Crypto::S
// 23. If abs(nanoseconds) ≥ abs(dayLengthNs), throw a RangeError exception.
auto nanoseconds_absolute = nanoseconds.is_negative() ? nanoseconds.negated_value() : nanoseconds;
auto compare_result = nanoseconds_absolute.compare_to_double(fabs(day_length_ns.to_double()));
- if (compare_result == Crypto::SignedBigInteger::CompareResult::DoubleLessThanBigInt || compare_result == Crypto::SignedBigInteger::CompareResult::DoubleEqualsBigInt)
+ if (compare_result == Crypto::UnsignedBigInteger::CompareResult::DoubleLessThanBigInt || compare_result == Crypto::UnsignedBigInteger::CompareResult::DoubleEqualsBigInt)
return vm.throw_completion<RangeError>(ErrorType::TemporalNanosecondsConvertedToRemainderOfNanosecondsLongerThanDayLength);
// 24. Return the Record { [[Days]]: days, [[Nanoseconds]]: nanoseconds, [[DayLength]]: abs(dayLengthNs) }.
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index 9ea8b4f4aa..dfee82f916 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -1536,7 +1536,7 @@ ThrowCompletionOr<bool> is_loosely_equal(VM& vm, Value lhs, Value rhs)
auto& number_side = lhs.is_number() ? lhs : rhs;
auto& bigint_side = lhs.is_number() ? rhs : lhs;
- return bigint_side.as_bigint().big_integer().compare_to_double(number_side.as_double()) == Crypto::SignedBigInteger::CompareResult::DoubleEqualsBigInt;
+ return bigint_side.as_bigint().big_integer().compare_to_double(number_side.as_double()) == Crypto::UnsignedBigInteger::CompareResult::DoubleEqualsBigInt;
}
// 14. Return false.
@@ -1635,10 +1635,10 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
VERIFY(!x_numeric.is_nan() && !y_numeric.is_nan());
if (x_numeric.is_number()) {
x_lower_than_y = y_numeric.as_bigint().big_integer().compare_to_double(x_numeric.as_double())
- == Crypto::SignedBigInteger::CompareResult::DoubleLessThanBigInt;
+ == Crypto::UnsignedBigInteger::CompareResult::DoubleLessThanBigInt;
} else {
x_lower_than_y = x_numeric.as_bigint().big_integer().compare_to_double(y_numeric.as_double())
- == Crypto::SignedBigInteger::CompareResult::DoubleGreaterThanBigInt;
+ == Crypto::UnsignedBigInteger::CompareResult::DoubleGreaterThanBigInt;
}
if (x_lower_than_y)
return TriState::True;