From d84c9e148b0d9544cc81096eb6183648396807ae Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 9 Feb 2018 18:56:40 +0100 Subject: [PATCH] Generic pretty-printed numbers.. --- libdevcore/CommonData.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index b85abe951..e410af5cc 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -155,6 +155,14 @@ inline std::string formatNumber(bigint const& _value) return _value.str(); } +inline std::string formatNumber(u256 const& _value) +{ + if (_value > 0x1000000) + return toHex(toCompactBigEndian(_value), 2, HexPrefix::Add); + else + return _value.str(); +} + inline std::string toCompactHexWithPrefix(u256 val) { std::ostringstream ret;