C++ 128/256-bit fixed size integer types

前端 未结 4 536
误落风尘
误落风尘 2020-12-03 14:27

I was wondering if any fellow SO\'s could recommend a good light-weight fixed size integer type (128-bit or even 256-bit, possibly even template parametrized) library.

4条回答
  •  -上瘾入骨i
    2020-12-03 15:07

    The Boost library has data types as part of multiprecision library, for types ranging from 128 to 1024 bits.

    #include 
    
    using namespace boost::multiprecision;
    
    int128_t mySignedInt128 = -1;
    uint128_t myUnsignedInt128 = 2;
    int256_t mySignedInt256 = -3;
    uint256_t myUnsignedInt256 = 4;
    int512_t mySignedInt512 = -5;
    uint512_t myUnsignedInt512 = 6;
    int1024_t mySignedInt1024 = -7;
    uint1024_t myUnsignedInt1024 = 8;
    

提交回复
热议问题