mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
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:
15
test/unit/stdlib/math/random_xorshiro.c3
Normal file
15
test/unit/stdlib/math/random_xorshiro.c3
Normal 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());
|
||||
}
|
||||
Reference in New Issue
Block a user