EOS contract uint128 convert to std::string

static const char* charmap = "0123456789";

std::string uint128ToString(const uint128_t& value)
{
    std::string result;
    result.reserve( 40 ); // max. 40 digits possible ( uint64_t has 20) 
    uint128_t helper = value;

    do {
        result += charmap[ helper % 10 ];
        helper /= 10;
    } while ( helper );
    std::reverse( result.begin(), result.end() );
    return result;
}

https://eosio.stackexchange.com/questions/2927/how-can-i-convert-a-uint128-t-to-a-string

版权属于:Surou

本文链接:https://www.bcskill.com/index.php/archives/821.html

相关技术文章仅限于相关区块链底层技术研究,禁止用于非法用途,后果自负!本站严格遵守一切相关法律政策!

评论