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
2
votes
0 answers

How to use the C library "_int128_t.h" in Cython

In the file .py I use the function: def xor(block: int, key: int) -> int: return block ^ key To which 128-bit numbers are transmitted. I want to replace it with a function implemented in Cython. But I can't figure out how to use 128-bit numbers…
Simon
  • 21
  • 1
2
votes
1 answer

Cannot overload std::abs() for GCC 128 bit integer

I'm getting compiler errors when I call abs() with GCC's 128 bit type. My line looks like: __extension__ using int128_t = __int128; int128_t mantissa_; // Other code using namespace std; int128_t temp = abs(mantissa_); The error I'm getting…
intrigued_66
  • 16,082
  • 51
  • 118
  • 189
2
votes
1 answer

128-bit integer in visual studio 6

Possible Duplicate: How to enable __int128 on Visual Studio? In Visual Studio 6, I've __int32 and __int64 integer data types but I can't have __int128 although I'm working on 64-bit machine.
Sherif
  • 1,249
  • 4
  • 15
  • 38
2
votes
1 answer

Any hope to convert a std::bitset<128> to a single 128-bit integer in the near future?

I am using std::bitset to represent short DNA sequences (haplotypes). For my purposes, I need to be able to convert each such sequence into a single integer. At the moment, it seems like this requirement bounds my sequences to be of length <=64…
gvbarroso
  • 21
  • 4
2
votes
0 answers

How to print __int128 in g++

I'm working with __int128s in g++ and need to print them. I found this question: How to print __int128 in g++? but it is 6 years old: is there a better way to do it in modern c++?
lolad
  • 321
  • 6
  • 13
2
votes
1 answer

Unsigned __int128 literal GCC

I have a function foo(unsigned __int128). How can I pass a literal of type unsigned __int128 to the function? My attempts: foo(0xFFFFFFFFFFFFFF23FFFFF); //Truncated (expected) foo(0xFFFFFFFFFFFFFFF01FFFu); //Truncated (expected) …
JCWasmx86
  • 3,473
  • 2
  • 11
  • 29
2
votes
5 answers

How to define INT128_MAX and INT128_MIN for __int128?

gcc has the __int128 type natively. However, it’s not defined in limits.h. I’m mean there’re no such things as INT128_MAX or INT128_MIN… And gcc is interpreting literal constants as 64 bits integers. This means that if I write #define INT128_MIN…
user2284570
  • 2,891
  • 3
  • 26
  • 74
2
votes
2 answers

gcc 7.3 128-bit unsigned integer operation

I'm confused with the usage of 128-bit integer. Please look at the test code: uint128_t test_data = 0x00000000FFFFFFFF0101010101010101; uint64_t test_data_h = test_data >> 64; uint64_t test_data_l = test_data ; printf("test_data 0x %016llx…
melquiades
  • 21
  • 3
2
votes
1 answer

Reading UINT 128 from Node JS Buffer

I am programming a Node JS client that's querying a third-party server for information. Part of the message that I receive back from the third party server is a UINT 128 (specified in documentation). However, from what I can tell, NodeJS buffers do…
greyvest
  • 23
  • 2
2
votes
1 answer

Divide 64-bit integers as though the dividend is shifted left 64 bits, without having 128-bit types

Apologies for the confusing title. I'm not sure how to better describe what I'm trying to accomplish. I'm essentially trying to do the reverse of getting the high half of a 64-bit multiplication in C for platforms where int64_t divHi64(int64_t…
superb owl
  • 185
  • 2
  • 13
2
votes
2 answers

How can I use a custom type for keys in a boost::unordered_map?

I'm using Boost's implementation of a hash map in a project right now, and I'm trying to implement a custom type for keys. I have four unsigned integers which I'd like to combine into a single 128-bit datatype to use as a key. I've created a struct…
jakogut
  • 4,409
  • 6
  • 29
  • 41
2
votes
1 answer

GCC alternative for Linux supporting OpenMP and 128-bit integers with +, -, *, /, and %

I have a C code that uses OpenMP and 128-bit integers. For the 128-bit integers, I'm using the __int128_t and __uint128_t extensions provided by GCC. I'm looking for any other compiler that can also compile this kind of code. Clang supports…
Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58
1
vote
4 answers

Squaring 2**32 into a 128-bit type fails

I would expect the following C code to produce 8, 16 for the first printf (it does), and 1, 0 for the second (however, it produces 0, 0). Why is that? (This is on MacOS on an Intel Core i7.) typedef unsigned long long ll; typedef unsigned __int128…
rogerl
  • 185
  • 2
  • 8
1
vote
2 answers

Output 128 bit integer using stream operator

I'm using GCC's 128 bit integer: __extension__ using uint128_t = unsigned __int128; uint128_t a = 545; std::cout << a << std::endl; However, if I try to output using the stream operator I get the compiler error: error: ambiguous overload for…
intrigued_66
  • 16,082
  • 51
  • 118
  • 189
1
vote
1 answer

Faster way to add an `__int128` to an `mpz_class` or `mpz_t` of the GMP library?

I want to do this with a 128 bit integer using g++ and GMP's mpz_class (or mpz_t): typedef unsigned __int128 tw_limb_t; mpz_class a = "1234567890123456789012345678901234567890"; tw_limb_t b = ...; a += b; I can do the following, but it seems slow…
Daniel S.
  • 6,458
  • 4
  • 35
  • 78