BigInt.h 793 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibCrypto/BigInt/SignedBigInteger.h>
  8. #include <LibJS/Heap/Cell.h>
  9. namespace JS {
  10. class BigInt final : public Cell {
  11. public:
  12. BigInt(Crypto::SignedBigInteger);
  13. virtual ~BigInt();
  14. const Crypto::SignedBigInteger& big_integer() const { return m_big_integer; }
  15. const String to_string() const { return String::formatted("{}n", m_big_integer.to_base(10)); }
  16. private:
  17. virtual const char* class_name() const override { return "BigInt"; }
  18. Crypto::SignedBigInteger m_big_integer;
  19. };
  20. BigInt* js_bigint(Heap&, Crypto::SignedBigInteger);
  21. BigInt* js_bigint(VM&, Crypto::SignedBigInteger);
  22. BigInt* number_to_bigint(GlobalObject&, Value);
  23. }