diff options
author | chriseth <chris@ethereum.org> | 2018-12-06 05:11:31 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-12-06 05:51:49 +0800 |
commit | bc6ddbdd09860542061baed8df993cb3dafaa406 (patch) | |
tree | 086050790c74a5d75eed165a545df11f9b554619 /libdevcore | |
parent | e8455c2a6d33abbebfe678fdaa1728311838e21a (diff) | |
download | dexon-solidity-bc6ddbdd09860542061baed8df993cb3dafaa406.tar.gz dexon-solidity-bc6ddbdd09860542061baed8df993cb3dafaa406.tar.zst dexon-solidity-bc6ddbdd09860542061baed8df993cb3dafaa406.zip |
Remove `w` parameter for toHex.
Diffstat (limited to 'libdevcore')
-rw-r--r-- | libdevcore/CommonData.cpp | 5 | ||||
-rw-r--r-- | libdevcore/CommonData.h | 6 | ||||
-rw-r--r-- | libdevcore/StringUtils.h | 6 |
3 files changed, 8 insertions, 9 deletions
diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp index 2c22fd9a..a289c8ed 100644 --- a/libdevcore/CommonData.cpp +++ b/libdevcore/CommonData.cpp @@ -29,7 +29,7 @@ using namespace std; using namespace dev; -string dev::toHex(bytes const& _data, int, HexPrefix _prefix, HexCase _case) +string dev::toHex(bytes const& _data, HexPrefix _prefix, HexCase _case) { std::ostringstream ret; int rix = _data.size() - 1; @@ -42,8 +42,7 @@ string dev::toHex(bytes const& _data, int, HexPrefix _prefix, HexCase _case) else if (_case == HexCase::Mixed) hexcase = (rix-- & 2) == 0 ? std::nouppercase : std::uppercase; - ret << std::hex << hexcase << std::setfill('0') << std::setw(_w) - << size_t(c); + ret << std::hex << hexcase << std::setfill('0') << std::setw(2) << size_t(c); } return (_prefix == HexPrefix::Add) ? "0x" + ret.str() : ret.str(); diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 6da2b292..7c59c505 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -61,7 +61,7 @@ enum class HexCase /// Convert a series of bytes to the corresponding string of hex duplets. /// @param _w specifies the width of the first of the elements. Defaults to two - enough to represent a byte. /// @example toHex("A\x69") == "4169" -std::string toHex(bytes const& _data, int _w = 2, HexPrefix _prefix = HexPrefix::DontAdd, HexCase _case = HexCase::Lower); +std::string toHex(bytes const& _data, HexPrefix _prefix = HexPrefix::DontAdd, HexCase _case = HexCase::Lower); /// Converts a (printable) ASCII hex character into the correspnding integer value. /// @example fromHex('A') == 10 && fromHex('f') == 15 && fromHex('5') == 5 @@ -153,7 +153,7 @@ inline std::string formatNumber(bigint const& _value) if (_value < 0) return "-" + formatNumber(-_value); if (_value > 0x1000000) - return toHex(toCompactBigEndian(_value), 2, HexPrefix::Add); + return toHex(toCompactBigEndian(_value), HexPrefix::Add); else return _value.str(); } @@ -161,7 +161,7 @@ inline std::string formatNumber(bigint const& _value) inline std::string formatNumber(u256 const& _value) { if (_value > 0x1000000) - return toHex(toCompactBigEndian(_value), 2, HexPrefix::Add); + return toHex(toCompactBigEndian(_value), HexPrefix::Add); else return _value.str(); } diff --git a/libdevcore/StringUtils.h b/libdevcore/StringUtils.h index 43aa4bd1..64044cb2 100644 --- a/libdevcore/StringUtils.h +++ b/libdevcore/StringUtils.h @@ -111,7 +111,7 @@ inline std::string formatNumberReadable( // 0x100 yields 2**8 (N is 1 and redundant) if (v == 1) return "2**" + std::to_string(i * 8); - return toHex(toCompactBigEndian(v), 2, prefix, hexcase) + + return toHex(toCompactBigEndian(v), prefix, hexcase) + " * 2**" + std::to_string(i * 8); } @@ -125,12 +125,12 @@ inline std::string formatNumberReadable( // 0xFF yields 2**8 - 1 (v is 0 in that case) if (v == 0) return "2**" + std::to_string(i * 8) + " - 1"; - return toHex(toCompactBigEndian(T(v + 1)), 2, prefix, hexcase) + + return toHex(toCompactBigEndian(T(v + 1)), prefix, hexcase) + " * 2**" + std::to_string(i * 8) + " - 1"; } - std::string str = toHex(toCompactBigEndian(_value), 2, prefix, hexcase); + std::string str = toHex(toCompactBigEndian(_value), prefix, hexcase); if (_useTruncation) { // return as interior-truncated hex. |