mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
LibCrypto: Add a way to compare UnsignedBigInteger with double
This patch also make SignedBigInteger::compare_to_double make use of the new function.
This commit is contained in:
parent
e03f014e7a
commit
54b8a2b094
7 changed files with 259 additions and 158 deletions
|
@ -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) }.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue