When saving and restoring a RNG state to a data file it may be important for the application to maintain portability in a binary file format. The byte ordering of the Rng_Type depends upon the details of the host architecture, so we provide routines to pack and unpack the Rng_Type in a given portable3 byte order. This character array of 8 unsigned bytes can be used to implement machine independent random number state in binary files, assuming that other tools are used to provide machine independent binary formats for the other C types used in the application. The routines to pack and unpack a Rng_Type to and from an unsigned char array of length 8 are, RngPack() and RngUnpack(), respectively: void RngPack( Rng_Type r, unsigned char *a );
Rng_Type RngUnpack( unsigned char *a ); The routine RngPack(r, a) takes a Rng_Type as its first argument, r, storing the 64-bit value in the unsigned char array (of length 8 bytes) referred to by its second argument, a. The routine RngUnpack(a) takes the 64-bit value stored in the unsigned char array (of length 8 bytes) referred to by the pointer, a, and returns the corresponding Rng_Type.