9

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
  • 1
    I tried, but... looks like it doesn't recognize __uint128_t as a native type... – Matteo Monti Jun 20 '11 at 16:54
  • I can't get __int128 to work in MSVC for either x86 or x64: error [C4235](http://msdn.microsoft.com/en-us/library/7e5yy2kb.aspx) not recognised on this architecture. – Rup Jun 20 '11 at 17:14
  • why are you wanting to do this? it won't be as optimal as natural integer sizes. Sounds like you want a basic bignum library. – IanNorton Jun 20 '11 at 19:31
  • @slartibartfast MinGW is a 32-bit compiler, which means there's no `__uint128_t` for you. You must use [mingw-w64](http://mingw-w64.sourceforge.net/) – phuclv Dec 28 '14 at 11:52
  • `__int128` is supported on 64-bit architectures only http://stackoverflow.com/questions/3329541/does-gcc-support-128-bit-int-on-amd64 – phuclv Jan 22 '15 at 06:47
  • [Here](https://developercommunity.visualstudio.com/t/Support-for-128-bit-integer-type/879048) is the quite lively feature request at visualstudio.com. – Spencer Nov 14 '22 at 16:21

2 Answers2

2

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.

phuclv
  • 37,963
  • 15
  • 156
  • 475
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084
  • That looked very good but.... "Unable to emulate TI" what does that mean? I've a i7 processor, 64 bit windows 7... what does this mean? Under linux 128 bit __uint128_t work perfectly, so... what does this mean? – Matteo Monti Jun 20 '11 at 17:34
  • @Matteo: Is your operating system 64bit, too? I'm not sure, the availability of the TI mode depends on the platform and it might just be that you don't have it... – Kerrek SB Jun 20 '11 at 17:46
0

You could try using SSE intrinsics built into Visual C++

http://msdn.microsoft.com/en-us/library/5eawz414%28v=VS.80%29.aspx (Look at the __m128 type).

selbie
  • 100,020
  • 15
  • 103
  • 173
  • 3
    SSE does not provide 128 bit integers, it provides only vectors of smaller integers (8-64 bit) which have a size of 128 bit as a whole. – Gunther Piez Oct 04 '12 at 15:28
  • SSE is not for 128-bit operations and you can't do normal 128-bit math efficiently with it. [practical BigNum AVX/SSE possible?](https://stackoverflow.com/q/27923192/995714), [Is it possible to use SSE and SSE2 to make a 128-bit wide integer?](https://stackoverflow.com/q/12200698/995714) – phuclv Apr 08 '22 at 12:58