Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What gcc versions support the __int128 intrinsic type? [duplicate]

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, 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.

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.

like image 902
Peeter Joot Avatar asked Feb 19 '14 16:02

Peeter Joot


People also ask

What is __ int128 in C++?

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.

Does C support 128-bit integers?

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.

How do you write a 128-bit integer?

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.

What is a 128-bit number?

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.


1 Answers

Not sure about the first version, but you can test for the __SIZEOF_INT128__ macro - which is (typically) 16 if defined.

like image 91
Brett Hale Avatar answered Sep 22 '22 17:09

Brett Hale