Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

128 bit integer with c on windows?

Is there any c compiler on windows able to use 128 bit integers natively? On example, you can use gcc on linux, with __uint128_t... any other chance on windows? (It would be great if 128 bit worked on 32 bit computers as well! :D)

Matteo

like image 895
Matteo Monti Avatar asked Jun 20 '11 16:06

Matteo Monti


People also ask

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.

Is there a 128-bit integer limit?

128-bit refers to one hundred twenty-eight binary (0 or 1) units of integer data. This allows for up to 340,282,366,920,938,463,463,374,607,431,768,211,456 combinations of values.

How many digits 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

In GCC you can try __attribute__((mode(...))), see here and here, e.g.

typedef unsigned int myU128 __attribute__((mode(TI)));

The results depend on your platform, though.

like image 169
Kerrek SB Avatar answered Sep 22 '22 23:09

Kerrek SB