EOS contract uint128 convert to std::string

2019-08-20 17:46:30
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

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »