4 ms·
Someone replied the following in there: "The key in this case is using C99's long long data type. It provides the biggest primitive storage C can manage (128-b
by Aardwolf 13y ago
Someone replied the following in there:
"The key in this case is using C99's long long data type. It provides the biggest primitive storage C can manage (128-bits on 32-bit machines and 256-bits on a 64-bit machine) and it runs really, really fast."
Isn't long long "typically" 64-bit? (I know the C standard doesn't actually specify any actual size).
What platform does this long long type really give you the full 128 or 256 bits on?
And do 64-bit CPU's indeed support 256 bit integer types? If so, what can I do to play with it!! C does not provide it for me on Linux!
Thanks :)
- longlonguserna 13y agoIf you want a guaranteed 64-bit type, put in your code: #include <stdint.h> then, use uint64_t for unsigned and int64_t for signed. If you want 128 bits, in gcc you can use __uint128_t (it has two extra underscores at the beginning because that size is nonstandard), but I don't think there is support for 256 bit integers. Try a big integer library: http://stackoverflow.com/questions/124332/c-handling-very-large-integers http://stackoverflow.com/questions/124332/c-handling-very-la...
- Moral_ 13y agoint64_t is just a typdef'd long long in linux and osx: typedef long long int int64_t;
- plorkyeran 13y agolong long is merely required to be at least 64-bit and in practice is 64-bit on every platform. AFAIK no general-purpose processors support 256-bit ints. AVX2 has 256-bit vector operations, but that is not at all the same thing.
- pdw 13y agogcc supports '__int128' and 'unsigned __int128' on 64-bit systems. They're pretty limited as there's no libc support for them on any system I know of.
- pbsd 13y agoPer the C99 standard, long long is guaranteed to be at least 64 bits, but is allowed to be larger.