Linear congruential generator: Difference between revisions
→{{header|jq}}: discuss gojq
m (→{{header|Wren}}: Minor tidy) |
(→{{header|jq}}: discuss gojq) |
||
Line 1,908:
=={{header|jq}}==
The Go implementation of jq (gojq) supports unlimited-precision integer arithmetic and therefore linear congruential generators (LCGs) can be trivially written for gojq.
The C implementation of jq, however, currently uses IEEE 754 64-bit numbers for arithmetic, so a BSD generator for the C implementation of jq would require some kind of "big integer" support.
In this entry, therefore, we first present functions for the Microsoft LCG that can be used with jq or gojq, and then present functions to support the BSD generator on the assumption that a suitable "BigInt" library is available.
====Microsoft LCG====
<syntaxhighlight lang="jq"># 15-bit integers generated using the same formula as rand()
|