Throw an exception when xoshiro seed is completely zero

This commit is contained in:
DBotThePony 2025-03-05 09:31:28 +07:00
parent f19804dd4a
commit 1a52864c4e
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -17,6 +17,15 @@ class Xoshiro256SSRandom(
) : RandomGenerator, RandomSource {
private val gaussian = MarsagliaPolarGaussian(this)
init {
require(
s0 != 0L ||
s1 != 0L ||
s2 != 0L ||
s3 != 0L
) { "Xoshiro can't operate with seed being entirely zero" }
}
constructor(seed: Long) : this(1L, 2L, 3L, 4L) {
setSeed(seed)
}