128-bit

How to know if __uint128_t is defined [duplicate]

亡梦爱人 提交于 2019-12-29 01:34:53
问题 This question already has answers here : Is there a 128 bit integer in gcc? (3 answers) Closed 8 months ago . We can use the preprocessor to know if unsigned long long is defined: #include <limits.h> #ifndef ULLONG_MAX typedef unsigned long t_mask; #else typedef unsigned long long t_mask; #endif But how to know if __uint128_t is defined? 回答1: You can try the following. I do not know how reliable this is, but it might be the easiest way. #ifdef __SIZEOF_INT128__ // do some fancy stuff here

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

試著忘記壹切 提交于 2019-12-24 04:43:22
问题 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 dividend, int64_t divisor) { return ((__int128)dividend << 64) / (__int128)divisor; } isn't possible due to lacking support for __int128 . 回答1: This can be done without a multi-word division Suppose we want to do ⌊2 64 × x ⁄ y ⌋ then we can transform

How to use Gcc 4.6.0 libquadmath and __float128 on x86 and x86_64

风格不统一 提交于 2019-12-20 09:20:00
问题 I have medium size C99 program which uses long double type (80bit) for floating-point computation. I want to improve precision with new GCC 4.6 extension __float128 . As I get, it is a software-emulated 128-bit precision math. How should I convert my program from classic long double of 80-bit to quad floats of 128 bit with software emulation of full precision? What need I change? Compiler flags, sources? My program have reading of full precision values with strtod , doing a lot of different

Are 64 bit programs bigger and faster than 32 bit versions?

只愿长相守 提交于 2019-12-18 10:06:57
问题 I suppose I am focussing on x86, but I am generally interested in the move from 32 to 64 bit. Logically, I can see that constants and pointers, in some cases, will be larger so programs are likely to be larger. And the desire to allocate memory on word boundaries for efficiency would mean more white-space between allocations. I have also heard that 32 bit mode on the x86 has to flush its cache when context switching due to possible overlapping 4G address spaces. So, what are the real benefits

How can I add and subtract 128 bit integers in C or C++ if my compiler does not support them?

你离开我真会死。 提交于 2019-12-17 06:11:21
问题 I'm writing a compressor for a long stream of 128 bit numbers. I would like to store the numbers as differences -- storing only the difference between the numbers rather than the numbers themselves because I can pack the differences in fewer bytes because they are smaller. However, for compression then I need to subtract these 128 bit values, and for decompression I need to add these values. Maximum integer size for my compiler is 64 bits wide. Anyone have any ideas for doing this efficiently

DataType for storing a long serial number (10 bytes)

限于喜欢 提交于 2019-12-11 18:34:21
问题 We have a device which has a 10 byte serial number which must be read into our application and stored into a .net datatype. In the device it is stored as an unsigned 10-byte (80-bit) number. I don't expect we will be performing any mathematical operations on this number, but only displaying it to the user. The .NET framework doesn't have a built in UNIT128 to store this datatype. My suggestion for storing this datatype is to create a 10 element byte array and read in the data into this array.

Is there a library or other way to do 128-bit math operations?

一笑奈何 提交于 2019-12-11 05:29:43
问题 I am writing a cryptography application and need to work with 128 bit integers. In addition to standard add, subtract, multiply, divide, and comparisons, I also need a power and modulo function as well. Does anyone know of a library or other implementation that can do this? If not 128-bit, is there a 64-bit option available? 回答1: Check out the GNU Multiple Precision Arithmetic Library. 回答2: Most any modern compiler is going to provide at least 64 bit through the use of the long long type. 回答3

128 bit integer with c on windows?

試著忘記壹切 提交于 2019-12-09 11:59:52
问题 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 回答1: 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. 回答2: You could try using SSE intrinsics built into Visual C++ http://msdn

128 bit arithmetic on x64 in C

陌路散爱 提交于 2019-12-06 05:06:44
问题 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 accessible from portable C (uint64_t). Similarly, on x64 it would be desirable to use 64-bit digits. This would require 128 bit arithmetic (i.e. 64+64=65, 64*64=128, 128/64=64). Fortunately, x64 provides this. Unfortunately, it's not accessible

128 bit arithmetic on x64 in C

有些话、适合烂在心里 提交于 2019-12-04 10:04:59
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 accessible from portable C (uint64_t). Similarly, on x64 it would be desirable to use 64-bit digits. This would require 128 bit arithmetic (i.e. 64+64=65, 64*64=128, 128/64=64). Fortunately, x64 provides this. Unfortunately, it's not accessible from portable C, though obviously one could dip into assembly. So my question is whether it's accessible