Added Xorshiro128++ random number generator. (#2846)

* Added Xorshiro128++ random number generator.

* Fixes to xorshiro implementation + tests.

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
Laura Kirsch
2026-02-06 20:14:56 +01:00
committed by GitHub
parent c57415ea78
commit 5b93212f43
3 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
module xorshiro_test;
import std::math;
fn void test_vectors_xorshiro() @test
{
Xorshiro128PPRandom a = { { 0x1, 0x2, 0x3, 0x4 } };
test::eq(0x281, a.next_int());
test::eq(0x180387, a.next_int());
test::eq(0xc0183387, a.next_int());
a = { { ~0x1, ~0x2, ~0x3, ~0x4 } };
test::eq(0xfffffcfd, a.next_int());
test::eq(0x17fbf8, a.next_int());
test::eq(0x40183386, a.next_int());
}