Functions

The u01 conversion functions

Functions

static float u01_closed_closed_32_24 (uint32_t i)
static float u01_closed_open_32_24 (uint32_t i)
static float u01_open_closed_32_24 (uint32_t i)
static float u01_open_open_32_24 (uint32_t i)
static double u01_closed_closed_64_53 (uint64_t i)
static double u01_closed_open_64_53 (uint64_t i)
static double u01_open_closed_64_53 (uint64_t i)
static double u01_open_open_64_53 (uint64_t i)
static double u01_closed_closed_32_53 (uint32_t i)
static double u01_closed_open_32_53 (uint32_t i)
static double u01_open_closed_32_53 (uint32_t i)
static double u01_open_open_32_53 (uint32_t i)

Detailed Description

These functions convert unsigned W-bit integers to real values (float or double) between 0.0 and 1.0 with mantissas of M bits. There are 12 functions, corresponding to the following choices:

The W=64 M=24 cases are not implemented. To obtain an M=24 float from a uint64_t, use a cast (possibly with right-shift and bitwise and) to convert some of the bits of the uint64_t to a uint32_t and then use u01_x_y_32_24. Note that the 64-bit random integers produced by the Random123 library are random in "all the bits", so with a little extra effort you can obtain two floats this way -- one from the high bits and one from the low bits of the 64-bit value.

If the output is open at one end, then the extreme value (0.0 or 1.0) will never be returned. Conversely, if the output is closed at one end, then the extreme value is a possible return value.

On x86 hardware, especially on 32bit machines, the use of internal 80bit x87-style floating point may result in 'bonus' precision, which may cause closed intervals to not be really closed, i.e. the conversions below might not convert UINT{32,64}_MAX to 1.0. This sort of issue is likely to occur when storing the output of a u01_*_32_24 function in a double, though one can imagine getting extra precision artifacts when going from 64_53 as well. Other artifacts may exist on some GPU hardware. The tests in kat_u01_main.h try to expose such issues, but caveat emptor.


Function Documentation

static float u01_closed_closed_32_24 ( uint32_t  i  )  [inline, static]
static double u01_closed_closed_32_53 ( uint32_t  i  )  [inline, static]
static double u01_closed_closed_64_53 ( uint64_t  i  )  [inline, static]
static float u01_closed_open_32_24 ( uint32_t  i  )  [inline, static]
static double u01_closed_open_32_53 ( uint32_t  i  )  [inline, static]
static double u01_closed_open_64_53 ( uint64_t  i  )  [inline, static]
static float u01_open_closed_32_24 ( uint32_t  i  )  [inline, static]
static double u01_open_closed_32_53 ( uint32_t  i  )  [inline, static]
static double u01_open_closed_64_53 ( uint64_t  i  )  [inline, static]
static float u01_open_open_32_24 ( uint32_t  i  )  [inline, static]
static double u01_open_open_32_53 ( uint32_t  i  )  [inline, static]
static double u01_open_open_64_53 ( uint64_t  i  )  [inline, static]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines