A better way to convert between uint160 and uint256 types.

This commit is contained in:
JoelKatz
2011-12-15 16:52:50 -08:00
parent 56484476a9
commit 8083b677e2
5 changed files with 24 additions and 27 deletions

View File

@@ -36,4 +36,18 @@ bool u160ToHuman(uint160& buf, std::string& retStr)
{
retStr=EncodeBase58(buf.begin(),buf.end());
return(true);
}
}
uint160 uint256::to160() const
{
uint160 m;
memcpy(&m, this, sizeof(uint160));
return m;
}
uint256 uint160::to256() const
{
uint256 m;
memcpy(&m, this, sizeof(this));
return m;
}