HPL_rand(3)
πΈ HPL_rand β random number generator π
okay bestie, welcome to the HPL_rand(3) page, a whole HPL Library Functions moment, and it's literally just the little chaos gremlin that spits out your random numbers β¨
β¨ SYNOPSIS β¨
#include "hpl.h"
double HPL_rand();
π¦ DESCRIPTION π¦
so HPL_rand generates the next number in the random sequence. that's it, that's the job π and it's highkey picky about it too β this function ensures that the number lands in the interval (-0.5, 0.5]. not gonna lie, that interval is giving "almost symmetric but not quite" and we respect it.
the static array irand is where the info lives β it holds the 2 integers you need to cook up the next number in the sequence X(n). here's the actual formula, no cap:
X(n) = (2^32 * irand[1] + irand[0]) / d - 0.5
where the constant d is the largest 64 bit positive integer. yes ma'am, the largest one. iconic behavior fr fr.
then irand gets updated so you can generate the next number X(n+1) in the random sequence, like this:
X(n+1) = a * X(n) + c
and the constants a and c? those should have been preliminarily stored in the arrays ias and ics as 2 pairs of integers π so like, they gotta be sitting there already, this function is not doing that for you, bestie.
and the initialization of ias, ics and irand? that's a whole separate serve β it's performed by the function HPL_setran. so go say hi to her first π
ngl if you skipped the setup step, you're on your own, this page is very clear that HPL_setran is the one who preps everything π
π SEE ALSO π
HPL_ladd (3)HPL_lmul (3)HPL_setran (3)HPL_xjumpm (3)HPL_jumpit (3)
and that's the whole page, bestie π«Ά this was HPL 2.2, dated February 24, 2016, from the HPL Library Functions collection. slay, stay random, bye πβ¨π
π¦ where this page comes from
- fedora 43: hpl-doc 2.2-22.fc43 Β· LicenseRef-Callaway-BSD-with-advertising
- fedora 44: hpl-doc 2.2-23.fc44 Β· LicenseRef-Callaway-BSD-with-advertising
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms