Under the gcc docs 128-bit integers is:
As an extension the integer scalar type
__int128
is supported for targets which have an integer mode wide enough to hold 128 bits. Simply write__int128
for a signed 128-bit integer, orunsigned __int128
for an unsigned 128-bit integer.There is no support in GCC for expressing an integer constant of type
__int128
for targets with long long integer less than 128 bits wide.
I was wondering what gcc version added support for this type, or if there's a macro that can be used directly to test for its existence.
The int128 type defines a signed 128-bit integer. The API is meant to mimic an intrinsic integer type as closely as possible, so that any forthcoming int128_t can be a drop-in replacement. The int128 type supports the following: Implicit conversion from signed integral types and unsigned types narrower than 128 bits.
Software. In the same way that compilers emulate e.g. 64-bit integer arithmetic on architectures with register sizes less than 64 bits, some compilers also support 128-bit integer arithmetic. For example, the GCC C compiler 4.6 and later has a 128-bit integer type __int128 for some architectures.
Simply write __int128 for a signed 128-bit integer, or unsigned __int128 for an unsigned 128-bit integer. There is no support in GCC for expressing an integer constant of type __int128 for targets with long long integer less than 128 bits wide.
The 128-bit data type can handle up to 31 significant digits (compared to 17 handled by the 64-bit long double). However, while this data type can store numbers with more precision than the 64-bit data type, it does not store numbers of greater magnitude.
Not sure about the first version, but you can test for the __SIZEOF_INT128__
macro - which is (typically) 16
if defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With