Questions tagged [int128]

Use this tag to refer to the 128-bit integers. For example, SIMD registers, a non-standard compiler extension on 64-bit platforms, or IPv6 addresses.

The 128-bit integers are a non-standard compiler extension on 64-bit platforms. The basic arithmetic and bitwise operations work on these data types in the same fashion as normal integers.

68 questions
184
votes
4 answers

How does Rust's 128-bit integer `i128` work on a 64-bit system?

Rust has 128-bit integers, these are denoted with the data type i128 (and u128 for unsigned ints): let a: i128 = 170141183460469231731687303715884105727; How does Rust make these i128 values work on a 64-bit system; e.g. how does it do arithmetic…
ruohola
  • 21,987
  • 6
  • 62
  • 97
81
votes
9 answers

What type should I use for a 128-bit number in in .NET?

I need to do some large integer math. Are there any classes or structs out there that represent a 128-bit integer and implement all of the usual operators? BTW, I realize that decimal can be used to represent a 96-bit int.
Adam Tegen
  • 25,378
  • 33
  • 125
  • 153
76
votes
3 answers

Is there a 128 bit integer in gcc?

I want a 128 bit integer because I want to store results of multiplication of two 64 bit numbers. Is there any such thing in gcc 4.4 and above?
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
58
votes
7 answers

How to print __int128 in g++?

I am using the GCC built-in type __int128 for a few things in my C++ program, nothing really significant, at least not enough to justify to use BigInt library only for that and, yet, enough to prevent to remove it totally. My problem comes when I…
perror
  • 7,071
  • 16
  • 58
  • 85
25
votes
7 answers

How to enable __int128 on Visual Studio?

When I type __int128 in a C++ project in Visual Studio, the editor changes color of __int128 to blue (like keyword). But when I compile the source, the folowing error appears: error C4235: nonstandard extension used : '__int128' keyword not…
Amir Saniyan
  • 13,014
  • 20
  • 92
  • 137
24
votes
5 answers

Is there hardware support for 128bit integers in modern processors?

Do we still need to emulate 128bit integers in software, or is there hardware support for them in your average desktop processor these days?
Filip Haglund
  • 13,919
  • 13
  • 64
  • 113
20
votes
2 answers

Numpy octuple precision floats and 128 bit ints. Why and how?

This is mostly a question out of curiosity. I noticed that the numpy test suite contains tests for 128 bit integers, and the numerictypes module refers to int128, float256 (octuple precision?), and other types that don't seem to map to numpy dtypes…
gerrit
  • 24,025
  • 17
  • 97
  • 170
17
votes
2 answers

How to create a 128-bit integer literal?

I have an integer literal in the format 0x75f17d6b3588f843b13dea7c9c324e51. Is there a way to avoid the compiler syntax error "integer literal is too large to be represented in any integer type"? Because I know I can work with those kinds of types…
Bida
  • 439
  • 1
  • 4
  • 13
16
votes
1 answer

128-bit integers supporting +, -, *, /, and % in the Intel C Compiler?

GCC and Clang have the __int128_t and __uint128_t extensions for 128-bit integer arithmetic. I was hopeful that __m128i would give something similar for the Intel C Compiler, but (if it's even possible) it looks to me like I'd have to write explicit…
Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58
11
votes
3 answers

How to use 128 bit integers in Cython

On my 64 bit computer the long long type has 64 bits. print(sizeof(long long)) # prints 8 I need to use 128 bit integers and luckily GCC supports these. How can I use these within Cython? The following doesn't work. Compiling foo.pyx containing…
chtenb
  • 14,924
  • 14
  • 78
  • 116
10
votes
3 answers

__uint128_t on mingw gcc

I'm trying to compile a c program under mingw gcc. This program is using an __uint128_t integer. When I try to compile it under the standard ubuntu gcc on the same 64-bit machine, it perfectly works. But then, when I try to compile it for windows…
Matteo Monti
  • 8,362
  • 19
  • 68
  • 114
10
votes
1 answer

Handling 128-bit integers with ctypes

What is the best way of supporting 128-bit integers (currently __uint128_t) with Python ctypes? A user-defined struct of two uint64_t's perhaps, but this will create alignment issues where that is required. Any thoughts on why ctypes has not been…
Fil
  • 1,766
  • 1
  • 15
  • 15
10
votes
1 answer

Bug with __int128_t in Clang?

This little code compiles with both GCC and Clang, but gives different results: #include int main(){ __int128_t test=10; while(test>0){ int myTest=(int)test; printf("? %d\n", myTest); test--; } } With GCC this counts…
Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58
9
votes
3 answers

Efficient way to store IPv4/IPv6 addresses

I am working on a C/C++ networking project that it should be able to both use the IPv4 and IPv6 networking stacks. The project works only on Linux. So, I tried to find an efficient way to store the IP addresses and differentiate between the…
evelina
  • 157
  • 1
  • 1
  • 8
8
votes
1 answer

How do I suppress the "ISO C++ does not support ‘__int128’ warning?

I'm compiling my code with gcc, with the -Wall -Wextra -Wpedantic switches and a non-extension standard set (say it's -std=c++14). But - I want to make an exception to that rule and use __int128. This gets me a warning: warning: ISO C++ does not…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
1
2 3 4 5