random-source-0.3.0.11: Generic basis for random number generators

Data.Random.Internal.Words

Description

A few little functions I found myself writing inline over and over again.

Synopsis

# Documentation

Build a word out of 2 bytes. No promises are made regarding the order in which the bytes are stuffed. Note that this means that a RandomSource or MonadRandom making use of the default definition of getRandomWord, etc., may return different random values on different platforms when started with the same seed, depending on the platform's endianness.

Build a word out of 4 bytes. No promises are made regarding the order in which the bytes are stuffed. Note that this means that a RandomSource or MonadRandom making use of the default definition of getRandomWord, etc., may return different random values on different platforms when started with the same seed, depending on the platform's endianness.

buildWord64 :: Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word64 Source #

Build a word out of 8 bytes. No promises are made regarding the order in which the bytes are stuffed. Note that this means that a RandomSource or MonadRandom making use of the default definition of getRandomWord, etc., may return different random values on different platforms when started with the same seed, depending on the platform's endianness.

Pack the low 23 bits from a Word32 into a Float in the range [0,1). Used to convert a stdUniform Word32 to a stdUniform Double.

Same as word32ToFloat, but also return the unused bits (as the 9 least significant bits of a Word32)

Pack the low 23 bits from a Word64 into a Float in the range [0,1). Used to convert a stdUniform Word64 to a stdUniform Double.

Same as wordToFloat, but also return the unused bits (as the 41 least significant bits of a Word64)

Pack the low 52 bits from a Word64 into a Double in the range [0,1). Used to convert a stdUniform Word64 to a stdUniform Double.

Pack a Word32 into a Double in the range [0,1). Note that a Double's mantissa is 52 bits, so this does not fill all of them.

Same as wordToDouble, but also return the unused bits (as the 12 least significant bits of a Word64)