1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

LibJS+LibLocale: Port Intl.NumberFormat to String

This commit is contained in:
Timothy Flynn 2023-01-22 11:55:26 -05:00 committed by Tim Flynn
parent 76fd5f2756
commit 0c2efa285a
13 changed files with 169 additions and 149 deletions

View file

@ -293,12 +293,16 @@ bool MathematicalValue::is_zero() const
[](auto) { return false; });
}
DeprecatedString MathematicalValue::to_deprecated_string() const
ThrowCompletionOr<String> MathematicalValue::to_string(VM& vm) const
{
return m_value.visit(
[](double value) { return number_to_deprecated_string(value, NumberToStringMode::WithoutExponent); },
[](Crypto::SignedBigInteger const& value) { return value.to_base_deprecated(10); },
[](auto) -> DeprecatedString { VERIFY_NOT_REACHED(); });
[&](double value) {
return number_to_string(vm, value, NumberToStringMode::WithoutExponent);
},
[&](Crypto::SignedBigInteger const& value) -> ThrowCompletionOr<String> {
return TRY_OR_THROW_OOM(vm, value.to_base(10));
},
[&](auto) -> ThrowCompletionOr<String> { VERIFY_NOT_REACHED(); });
}
Value MathematicalValue::to_value(VM& vm) const