mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
This allows us to support parsing and serializing BigIntegers to and from any base N (such that 2 <= N <= 36).
30 lines
690 B
C++
30 lines
690 B
C++
/*
|
|
* Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
|
#include <LibJS/Heap/Cell.h>
|
|
|
|
namespace JS {
|
|
|
|
class BigInt final : public Cell {
|
|
public:
|
|
BigInt(Crypto::SignedBigInteger);
|
|
virtual ~BigInt();
|
|
|
|
const Crypto::SignedBigInteger& big_integer() const { return m_big_integer; }
|
|
const String to_string() const { return String::formatted("{}n", m_big_integer.to_base(10)); }
|
|
|
|
private:
|
|
virtual const char* class_name() const override { return "BigInt"; }
|
|
|
|
Crypto::SignedBigInteger m_big_integer;
|
|
};
|
|
|
|
BigInt* js_bigint(Heap&, Crypto::SignedBigInteger);
|
|
|
|
}
|