Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JeffersonLab/drand48
Nim implementation of standard unix drand48 random number generator
https://github.com/JeffersonLab/drand48
Last synced: 3 months ago
JSON representation
Nim implementation of standard unix drand48 random number generator
- Host: GitHub
- URL: https://github.com/JeffersonLab/drand48
- Owner: JeffersonLab
- License: bsd-3-clause
- Created: 2017-09-29T16:22:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-22T22:06:56.000Z (almost 4 years ago)
- Last Synced: 2024-05-18T14:33:39.839Z (6 months ago)
- Language: Nim
- Size: 15.6 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nim - drand48 - Nim implementation of the standard Unix drand48 random number generator. (Operating System / Randomization)
README
# Drand48 [![Build Status](https://travis-ci.org/JeffersonLab/drand48.svg?branch=master)](https://travis-ci.org/JeffersonLab/drand48)
Nim implementation of the standard unix drand48 pseudo random number generator.
All the routines work by generating a sequence of 48-bit integer values, Xi ,
according to the linear congruential formula:Xn+1 = (aXn + c) mod m n>= 0
The parameter m = 248; hence 48-bit integer arithmetic is performed.
The multiplier value a and the addend value c are given by:a = 0x5DEECE66D = 0c273673163155
c = 0xB = oc13The value returned by any of the drand48() is computed by first
generating the next 48-bit Xi in the sequence. Then the appropriate
number of bits, according to the type of data item to be returned, are
copied from the high-order (leftmost) bits of Xi and transformed into the returned value.
The drand48() function stores the last 48-bit Xi generated in an
internal buffer; that is why they must be initialised prior to being invoked.The initializer function srand48() sets the high-order 32 bits of Xi to
the low-order 32 bits contained in its argument. The low-order 16 bits
of Xi are set to the arbitrary value 0x330E .The initializer function seed48() sets the value of Xi to the 48-bit value
specified in the argument array. The seed can be set with the 48-bit
seed split into four 12-bit chunks, or as a 48-bit int.There are functions savern12() and savern48() that returns the current random number seed.