chfast / intx

Extended precision integer C++ library
Apache License 2.0
129 stars 29 forks source link

Questions! #266

Closed greg7mdp closed 2 years ago

greg7mdp commented 2 years ago

Hi Pawel, instead of having #if INTX_HAS_BUILTIN_INT128 in multiple APIs, why not just do:

#if INTX_HAS_BUILTIN_INT128
    using uint128 = builtin_uint128;
#else
    using uint128 = uint<128>;
#endif
greg7mdp commented 2 years ago

Never mind, I think I understand why it is more practical to do it your way.

chfast commented 2 years ago

We really want to use umul instruction which does 64x64 → 128 multiplication. The way to get it on GCC and Clang is to use __int128 type. On MSVC there is the intrinsic.