Is it possible for lcg_value () to roll a perfect 1?
1 answer
-
The test shows that 0 and 1 are valid values. But...
-
PHP uses the Combined Linear Congruential Generator . Like the wiki, the value
R
cannot be equal0
(due to checking this) and cannot be equal1
(becauseX
lessm
(because X is the result of a modulem - 1
))
So the result lcg_value
belongs to (0,1) not to [0,1]
+2
source to share