diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-08-24 07:27:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-24 07:27:09 +0800 |
commit | 957f23a9f4cb181b2dfaf0170816080513bfe786 (patch) | |
tree | c1d6de873c54380018f6a88d2fe687b5770c6db7 /libdevcore | |
parent | ee8fa886cc0fa39ae9c41e9685a576166362906c (diff) | |
parent | cf5e1d6120513c757bd5c71f1e3af972a9a63aeb (diff) | |
download | dexon-solidity-957f23a9f4cb181b2dfaf0170816080513bfe786.tar.gz dexon-solidity-957f23a9f4cb181b2dfaf0170816080513bfe786.tar.zst dexon-solidity-957f23a9f4cb181b2dfaf0170816080513bfe786.zip |
Merge pull request #2538 from ethereum/z3Conditions
z3 conditions
Diffstat (limited to 'libdevcore')
-rw-r--r-- | libdevcore/CommonData.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 0321011e..5df8986a 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -145,6 +145,17 @@ inline std::string toHex(u256 val, HexPrefix prefix = HexPrefix::DontAdd) return (prefix == HexPrefix::Add) ? "0x" + str : str; } +/// Returns decimal representation for small numbers and hex for large numbers. +inline std::string formatNumber(bigint const& _value) +{ + if (_value < 0) + return "-" + formatNumber(-_value); + if (_value > 0x1000000) + return toHex(toCompactBigEndian(_value), 2, HexPrefix::Add); + else + return _value.str(); +} + inline std::string toCompactHexWithPrefix(u256 val) { std::ostringstream ret; |