diff --git a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h index bf606d8fc95..adac4695c2b 100644 --- a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h +++ b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h @@ -172,8 +172,26 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder&, Crypto::UnsignedBigInteger const&); }; -inline Crypto::UnsignedBigInteger -operator""_bigint(char const* string, size_t length) +inline Crypto::UnsignedBigInteger operator""_bigint(char const* string, size_t length) { return MUST(Crypto::UnsignedBigInteger::from_base(10, { string, length })); } + +inline Crypto::UnsignedBigInteger operator""_bigint(unsigned long long value) +{ + auto result = Crypto::UnsignedBigInteger { static_cast(value) }; + VERIFY(!result.is_invalid()); + + return result; +} + +inline Crypto::UnsignedBigInteger operator""_bigint(long double value) +{ + VERIFY(value >= 0); + VERIFY(value < static_cast(NumericLimits::max())); + + auto result = Crypto::UnsignedBigInteger { static_cast(value) }; + VERIFY(!result.is_invalid()); + + return result; +}