From 6a857f67d37db77a7cdda6ebc9d45837eadc39a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 3 Oct 2023 18:52:12 +0200 Subject: [PATCH] lcg_value: Include the caution from Randomizer::nextFloat() see php/doc-en#2825 --- reference/random/functions/lcg-value.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/reference/random/functions/lcg-value.xml b/reference/random/functions/lcg-value.xml index 44e2d991fd2f..317235bab81c 100644 --- a/reference/random/functions/lcg-value.xml +++ b/reference/random/functions/lcg-value.xml @@ -18,6 +18,21 @@ to the product of both primes. &caution.cryptographically-insecure; + + + Scaling the return value to a different interval using multiplication + or addition (a so-called affine transformation) might result in a bias + in the resulting value as floats are not equally dense across the number + line. As not all values can be exactly represented by a float, the + result of the affine transformation might also result in values outside + of the requested interval. + + + Use Random\Randomizer::getFloat to generate a + random float within an arbitrary interval. Use Random\Randomizer::getInt + to generate a random integer within an arbitrary interval. + +