by pps43 · 6y ago · 0 comments
static uint128_t state = 1; // can be seeded to any odd number
static inline uint64_t next(){
return (state *= 0xda942042e4dd58b5ULL) >> 64;
}
from http://www.pcg-random.org/posts/on-vignas-pcg-critique.html?GCC and clang do have a 128-bit integral type, __int128, but arithmetic operations are synthesized inline, and judging by the generated assembly don't even make use of SIMD at all.
Note that an unintended consequence of C99's uintmax_t made the introduction of a standard 128-bit integral type impossible on platforms that cared about ABI compatibility, an effect somewhat contradictory to the original intention of improving portability and code integration. A future C standard will loosen some language and introduce some new facilities to help promote the introduction of larger integral types. At that point Unix platforms may begin typedef'ing __int128 to int128_t.