Questions tagged [128-bit]

Referring to computer architecture with addresses and other data units 128 bits wide.

85 questions
9
votes
2 answers

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
Matteo Monti
  • 8,362
  • 19
  • 68
  • 114
8
votes
2 answers

128-bit shifts using assembly language?

What is the most efficient way to do 128 bit shift on a modern Intel CPU (core i7, sandy bridge). A similar code is in my most inner loop: u128 a[N]; void xor() { for (int i = 0; i < N; ++i) { a[i] = a[i] ^ (a[i] >> 1) ^ (a[i] >> 2); …
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208
8
votes
2 answers

Is 128-bit "long-float" useful?

I realized the other day that most common lisp had 128-bit "long-floats". As a result, the most positive long float is: 8.8080652584198167656 * 10^646456992 while the most positive double float is 1.7976931348623157 * 10^308, which is pretty big…
Thaddee Tyl
  • 1,126
  • 1
  • 12
  • 17
8
votes
4 answers

Is there any way to do 128-bit shifts on gcc <4.4?

gcc 4.4 seems to be the first version when they added int128_t. I need to use bit shifting and I have run out of room for some bit fields. Edit: It might be because I'm on a 32-bit computer, there's no way to have it for a 32-bit computer (Intel…
Roman A. Taycher
  • 18,619
  • 19
  • 86
  • 141
8
votes
3 answers

How does this 128 bit integer multiplication work in assembly (x86-64)?

I'm reading Computer Systems: A Programmer's Perspective and the homework was to describe how this algorithm works. C function: void store_prod(__int128 *dest, int64_t x, int64_t y) { *dest = x * (__int128)y; } Assembly: movq %rdx,…
denis631
  • 1,765
  • 3
  • 17
  • 38
8
votes
6 answers

Fastest way to convert binary to decimal?

I've got four unsigned 32-bit integers representing an unsigned 128-bit integer, in little endian order: typedef struct { unsigned int part[4]; } bigint_t; I'd like to convert this number into its decimal string representation and output it to…
ianh
  • 836
  • 1
  • 5
  • 15
7
votes
4 answers

Unsigned 128-bit division on 64-bit machine

I have a 128-bit number stored as 2 64-bit numbers ("Hi" and "Lo"). I need only to divide it by a 32-bit number. How could I do it, using the native 64-bit operations from CPU? (Please, note that I DO NOT need an arbitrary precision library. Just…
rookie
  • 205
  • 1
  • 3
  • 6
5
votes
1 answer

128 bit Int in SQL Server 2012?

I'm looking for the best way to implement 128 bit unsigned integers in SQL Server. The main requirement is that it must support bitwise operations across all 128 bits. (Is this even theoretically possible on a 64 bit machine? I digress.) I've read…
vimfluencer
  • 3,106
  • 3
  • 17
  • 25
4
votes
1 answer

C++ - GMP pow() function

I am trying to do pow(2,500) in C++. But I think long long is not enough. Someone told me I can use gmp.h. But how do I do a pow(2,500) in gmp?
JJ Liu
  • 1,351
  • 8
  • 20
  • 36
4
votes
2 answers

128-bit arithmetic on x64 in C

When implementing bignums on x86, obviously the most efficient choice for digit size is 32 bits. However, you need arithmetic up to twice the digit size (i.e. 32+32=33, 32*32=64, 64/32=32). Fortunately, not only does x86 provide this, but it's also…
rwallace
  • 31,405
  • 40
  • 123
  • 242
3
votes
2 answers

Fixed size integers with gmp...?

I've been trying for days to install GMP library under MINGW. I have been using for weeks __uint128_t with gcc under a linux64 bit environment, then ported the same program under GMP and mingw (32 bit version). I used mpz_class integers instead of…
Matteo Monti
  • 8,362
  • 19
  • 68
  • 114
3
votes
2 answers

How to divide a 128-bit dividend by a 64-bit divisor, where the dividend's bits are all 1's, and where I only need the 64 LSBs of the quotient?

I need to calculate (2128 - 1) / x. The divisor, x, is an unsigned 64-bit number. The dividend is composed of two unsigned 64-bit numbers (high and low), where both numbers are UINT64_MAX. I can only use 64-bit arithmetic and need it to be portable…
tgonzalez89
  • 621
  • 1
  • 6
  • 26
3
votes
1 answer

Unable to compile assembly code with xmmword operand-size using nasm

I was trying to compile an assembly code using nasm (nasm -o file input.asm) and threw an error at line 2 in the following code snippet: mov rsi, 0x400200 movdqu xmm0,xmmword [rsi] nop I am not sure if instructions with 128 bit registers can be…
Goks
  • 33
  • 4
3
votes
1 answer

Why does C#'s decimal use binary integer significand?

The new IEEE 128-bit decimal floating-point type https://en.wikipedia.org/wiki/Decimal128_floating-point_format specifies that the significand (mantissa) can be represented in one of two ways, either as a simple binary integer, or in densely packed…
rwallace
  • 31,405
  • 40
  • 123
  • 242
3
votes
3 answers

128 bit representation and primitives in java

I need to represent 128 bit int key in java, like 0x9c1f03a0d9cf510f2765bd0f226ff5dc I know how represent 128 bit variable in theory.. cut into 2 64 bit int or four 32 bit int. But i need this representation for compare keys (k1 < k2 and k1 == k2)…
Master AI
  • 33
  • 1
  • 3