RandomLib
1.10
|
Class to hold bit-width and unsigned type. More...
#include <RandomLib/RandomType.hpp>
Public Types | |
typedef UIntType | type |
Static Public Member Functions | |
template<typename IntType > | |
static type | cast (IntType x) throw () |
static void | Read32 (std::istream &is, bool bin, type &x) |
static void | Write32 (std::ostream &os, bool bin, int &cnt, type x) |
static void | CheckSum (type n, uint32_t &check) throw () |
Static Public Attributes | |
static const unsigned | width = bits |
static const type | mask |
static const type | min = type(0) |
static const type | max = mask |
Class to hold bit-width and unsigned type.
This provides a simple class to couple a bit-width and an unsigned type capable of holding all the bits. In addition is offers static methods for I/O and checksumming.
bits | the number of significant bits. |
UIntType | the C++ unsigned integer type capable of holding the bits. |
Definition at line 32 of file RandomType.hpp.
typedef UIntType RandomLib::RandomType< bits, UIntType >::type |
The unsigned C++ type
Definition at line 37 of file RandomType.hpp.
|
inlinestatic |
A combined masking and casting operation
IntType | the integer type of the x. |
[in] | x | the input integer. |
Definition at line 62 of file RandomType.hpp.
Referenced by RandomLib::RandomSeed::SeedVector(), RandomLib::RandomSeed::SeedWord(), and RandomLib::RandomSeed::StringToVector().
|
static |
Read a data value from a stream of 32-bit quantities (binary or text)
[in,out] | is | the input stream. |
[in] | bin | true if the stream is binary. |
[out] | x | the data value read from the stream. |
Definition at line 125 of file Random.cpp.
References RandomLib::RandomType< bits, UIntType >::mask.
|
static |
Write the data value to a stream of 32-bit quantities (binary or text)
[in,out] | os | the output stream. |
[in] | bin | true if the stream is binary. |
[in,out] | cnt | controls the use of spaces and newlines for text output. |
[in] | x | the data value to be written to the stream. |
cnt should be zero on the first invocation of a series of writes. This function increments it by one on each call.
Definition at line 99 of file Random.cpp.
|
static |
Accumulate a checksum of a integer into a 32-bit check. This implements a very simple checksum and is intended to avoid accidental corruption only.
[in] | n | the number to be included in the checksum. |
[in,out] | check | the running checksum. |
Referenced by RandomLib::RandomSeed::SeedWord().
|
static |
The number of significant bits
Definition at line 41 of file RandomType.hpp.
|
static |
A mask for the significant bits.
Definition at line 45 of file RandomType.hpp.
Referenced by RandomLib::RandomCanonical< Generator >::Integer(), RandomLib::RandomCanonical< Generator >::IntegerC(), and RandomLib::RandomType< bits, UIntType >::Read32().
|
static |
The minimum representable value
Definition at line 50 of file RandomType.hpp.
|
static |
The maximum representable value
Definition at line 54 of file RandomType.hpp.