# Download the PCG Library

## Minimal C Implementation

If you just want a good RNG with the least amount of code possible, you may be fine with the minimal C implementation. In fact, if you want to “see the code”, the here's a complete PCG generator:

// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-random.org // Licensed under Apache License 2.0 (NO WARRANTY, etc. see website) typedef struct { uint64_t state; uint64_t inc; } pcg32_random_t; uint32_t pcg32_random_r(pcg32_random_t* rng) { uint64_t oldstate = rng->state; // Advance internal state rng->state = oldstate * 6364136223846793005ULL + (rng->inc|1); // Calculate output function (XSH RR), uses old state for max ILP uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u; uint32_t rot = oldstate >> 59u; return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); }

Although you could just copy and paste this code, the actual downloadable version of the minimal library handles proper seeding and generating numbers within a set range, and provides some demo programs to show it in use.

See the documentation for the minimal library for more details on how to use this library. You can also find the code on github.

PCG Random, Minimal C Implementation, 0.9## C++ Implementation

This version of the code is a header-only C++ library, modeled after the C++11 random-number facility. If you can use C++ in your project, you should probably use this version of the library.

See the documentation for the C++ library for more details on how to use this library. You can also find the code on github.

PCG Random, C++ Implementation, 0.98## C Implementation

This version of the library provides many features of the C++ library to programmers working in C.

See the documentation for the full C library for more details on how to use this library. You can also find the code on github.

PCG Random, C Implementation, 0.94## Haskell Implementation

Christopher Chalmers has ported the basic C implementation to Haskell. His code is available on GitHub. At a glance, it should be installable via Cabal. Thanks Christopher!

## Java Implementation

Coming later... (you could help!)

## Other Languages

Coming later... (you could help!)