Skip to content

Commit

Permalink
merged changes from branch to master
Browse files Browse the repository at this point in the history
  • Loading branch information
scadding committed Jan 15, 2017
1 parent c4639aa commit c732e98
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/uint256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ std::string base_uint<BITS>::ToString() const
return (GetHex());
}

template <unsigned int BITS>
std::string base_uint<BITS>::ToStringReverseEndian() const
{
char psz[sizeof(pn) * 2 + 1];
for (unsigned int i = 0; i < sizeof(pn); i++)
sprintf(psz + i * 2, "%02x", ((unsigned char*)pn)[i]);
return std::string(psz, psz + sizeof(pn) * 2);
}

template <unsigned int BITS>
unsigned int base_uint<BITS>::bits() const
{
Expand Down Expand Up @@ -248,6 +257,15 @@ template std::string base_uint<256>::ToString() const;
template void base_uint<256>::SetHex(const char*);
template void base_uint<256>::SetHex(const std::string&);
template unsigned int base_uint<256>::bits() const;
template std::string base_uint<256>::ToStringReverseEndian() const;

// Explicit instantiations for base_uint<512>
template base_uint<512>::base_uint(const std::string&);
template base_uint<512>& base_uint<512>::operator<<=(unsigned int);
template base_uint<512>& base_uint<512>::operator>>=(unsigned int);
template std::string base_uint<512>::GetHex() const;
template std::string base_uint<512>::ToString() const;
template std::string base_uint<512>::ToStringReverseEndian() const;

// This implementation directly uses shifts instead of going
// through an intermediate MPI representation.
Expand Down
8 changes: 8 additions & 0 deletions src/uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class base_uint
void SetHex(const char* psz);
void SetHex(const std::string& str);
std::string ToString() const;
std::string ToStringReverseEndian() const;

unsigned char* begin()
{
Expand Down Expand Up @@ -379,4 +380,11 @@ class uint512 : public base_uint<512> {
}
};

inline uint512 uint512S(const std::string& str)
{
uint512 rv;
rv.SetHex(str);
return rv;
}

#endif // BITCOIN_UINT256_H

0 comments on commit c732e98

Please sign in to comment.