diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp index 59aaf1933db..0787f90eb1e 100644 --- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp @@ -308,3 +308,10 @@ bool SignedBigInteger::operator>=(const SignedBigInteger& other) const } } + +ErrorOr AK::Formatter::format(FormatBuilder& fmtbuilder, const Crypto::SignedBigInteger& value) +{ + if (value.is_negative()) + TRY(fmtbuilder.put_string("-")); + return Formatter::format(fmtbuilder, value.unsigned_value()); +} diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h index f85a4969d96..9bec7187944 100644 --- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h +++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h @@ -143,6 +143,11 @@ struct SignedDivisionResult { } +template<> +struct AK::Formatter : AK::Formatter { + ErrorOr format(FormatBuilder&, Crypto::SignedBigInteger const&); +}; + inline Crypto::SignedBigInteger operator""_sbigint(const char* string, size_t length) {