Browse Source

most compact number representation

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
1d4e61167f
  1. 5
      libdevcore/CommonJS.h

5
libdevcore/CommonJS.h

@ -38,7 +38,10 @@ template <unsigned S> std::string toJS(FixedHash<S> const& _h)
template <unsigned N> std::string toJS(boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N, N, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> const& _n)
{
return "0x" + toHex(toCompactBigEndian(_n, 1));
std::string h = toHex(toCompactBigEndian(_n, 1));
// remove first 0, if it is necessary;
std::string res = h[0] != '0' ? h : h.substr(1);
return "0x" + res;
}
inline std::string toJS(bytes const& _n, std::size_t _padding = 0)

Loading…
Cancel
Save