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
1
vote
0 answers

gcc turning on -O3 causes bug on 128 bit integer

Two versions of a function that multiplies a unsigned 256 bit integer by constant 977. (for cryptography application) Note __int128_t type is used in the 2nd function. #include #include // z,z_carry = uint256(y) * 977 static…
Kh40tiK
  • 2,276
  • 19
  • 29
1
vote
1 answer

Python C-API int128 support

In python one can handle very large integers (for instance uuid.uuid4().int.bit_length() gives 128), but the largest int datastructure the C-API documentation offers is long long, and it is a 64-bit int. I would love to be able to get a C int128…
azmeuk
  • 4,026
  • 3
  • 37
  • 64
1
vote
1 answer

How to bit scan forward and reverse a __uint128_t (128bit)?

I have done with bit scan forward/reverse a 64bit using DeBruijn algorithm but cannot archive 128bit, __uint128_t. Is there any solution? Thanks in advance! FYI code for bit scan forward/reverse a 64bit using DeBruijn algorithm: constexpr…
Nikel Arteta
  • 548
  • 1
  • 6
  • 25
1
vote
3 answers

Is a 128 bit int written or loaded in two instructions in C/C++?

I know that there exists a int128_t type in C and C++. If I have two threads one that is reading from a memory location containing this 128 bit integer and another that is writting to it. Is there a chance that this value will be written as two 64…
Marcus Karpoff
  • 451
  • 5
  • 16
1
vote
5 answers

How to properly add/subtract a 128-bit number (as two uint64_t)?

I'm working in C and need to add and subtract a 64-bit number and a 128-bit number. The result will be held in the 128-bit number. I am using an integer array to store the upper and lower halves of the 128-bit number (i.e. uint64_t bigNum[2], where…
Joe Boo
  • 105
  • 3
  • 10
1
vote
2 answers

Issue clearing bits in 128 bit integer array

My goal with this program is that I want to be able to set 1000 bits to 0 or 1 separately, for this I'm using an array of 128 bit integers. Now the issue is when I simply clear_bit(3), bit 35 is also being cleared (and vice versa). 3 & 35 are…
SJ19
  • 1,933
  • 6
  • 35
  • 68
1
vote
1 answer

redis store 128 bit number

I want to efficiently search IPv6 subnet range using redis. i thought of storing the IPv6 numeric addresses in redis and search them by range. those are 128-bit ints, e.g: import ipaddress int(ipaddress.ip_address(u'113f:a:2:3:4:1::77')) >…
SagyDrucker
  • 21
  • 1
  • 3
1
vote
0 answers

error in count leading zeros of __int128_t

#include #include using namespace std; typedef __int128_t int128_t; int main() { int128_t y = 0; cout<<__builtin_clzll(static_cast(y>>64)) <
Zuo Wang
  • 43
  • 2
1
vote
1 answer

Multiple VC compile errors

I'm using VC++ to write a 128-bit integer "class" in C (wrapped the header in extern "C" block), however, during routine builds to check for errors, I encountered many after adding this function: /* Negate (2s compliment NOT) a 128-bit integer…
Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
1
vote
1 answer

How to convert a decimal ascii string to integer array in C?

I have written a program that works with IPv6 addresses, and I needed code that converts a four-integer array to decimal string that represented number of IPv6 addresses[1]. Now I ran into the situation when I need to do reverse: convert possibly…
user1728756
0
votes
2 answers

ASM/NASM - Return high low of a MUL in a type struct

global mymul mymul: mov rax, rdi mul rsi ret #include typedef struct { unsigned long long high; unsigned long long low; } resmul; void mymul(unsigned long long, unsigned long long, resmul *res); int…
1111 B
  • 1
0
votes
0 answers

program termination only in release mode when using __int128 and templates

I wrote some kind of index and I am trying to use it. When I run the program in debug mode everything seems to be fine, but in release mode the program exits with code -1073741819 (hex: ‭FFFFFFFFC0000005‬); this seems to be an access violation. The…
lxndr
  • 85
  • 4
0
votes
1 answer

How to write 128Int or 256Int to Buffer in nodejs

I have a BigInt 170141183460469231731687303715884105728n which is 128 bit integer, then i want to convert that integer to buffer. But as i know, nodejs Buffer is doesn't support 128 or 256 bit integer, only 64 bit integer they supported. So the…
butthx
  • 11
  • 1
  • 4
0
votes
0 answers

asm x86_64 Intel Linux - Move RDX:RAX into XMM0

I'm using rdtsc instruction and i know that it stores the high quadword into RDX and the low quadword into RAX (RDX:RAX) but i want to do arithmetic with this (substraction of two timestamps) So i need to move RDX:RAX into a 128 bits register…
0xDEADBEEF
  • 66
  • 7
0
votes
0 answers

cout cannot print __int128 - MinGW-w64

Previously I noticed that GCC has built-in support for 128-bit integer. now I'm trying it under MinGW but there are two problems with that: I can't print it using cout. I can't convert it to string neither by string's constructor nor by functions…