mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
LibJS: Define BigInt::to_string to complement to_deprecated_string
This commit is contained in:
parent
b245300ba1
commit
7a7a649f5b
2 changed files with 10 additions and 1 deletions
|
@ -22,6 +22,11 @@ BigInt::BigInt(Crypto::SignedBigInteger big_integer)
|
||||||
VERIFY(!m_big_integer.is_invalid());
|
VERIFY(!m_big_integer.is_invalid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<String> BigInt::to_string() const
|
||||||
|
{
|
||||||
|
return String::formatted("{}n", TRY(m_big_integer.to_base(10)));
|
||||||
|
}
|
||||||
|
|
||||||
// 21.2.1.1.1 NumberToBigInt ( number ), https://tc39.es/ecma262/#sec-numbertobigint
|
// 21.2.1.1.1 NumberToBigInt ( number ), https://tc39.es/ecma262/#sec-numbertobigint
|
||||||
ThrowCompletionOr<BigInt*> number_to_bigint(VM& vm, Value number)
|
ThrowCompletionOr<BigInt*> number_to_bigint(VM& vm, Value number)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Error.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||||
#include <LibJS/Heap/Cell.h>
|
#include <LibJS/Heap/Cell.h>
|
||||||
|
@ -21,7 +23,9 @@ public:
|
||||||
virtual ~BigInt() override = default;
|
virtual ~BigInt() override = default;
|
||||||
|
|
||||||
Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
|
Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
|
||||||
const DeprecatedString to_deprecated_string() const { return DeprecatedString::formatted("{}n", m_big_integer.to_base_deprecated(10)); }
|
|
||||||
|
ErrorOr<String> to_string() const;
|
||||||
|
DeprecatedString to_deprecated_string() const { return DeprecatedString::formatted("{}n", m_big_integer.to_base_deprecated(10)); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit BigInt(Crypto::SignedBigInteger);
|
explicit BigInt(Crypto::SignedBigInteger);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue