Avril 4 years ago
parent 7269a99aa6
commit 48301abe6b
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -33,7 +33,7 @@ std::int32_t RNG::next_int(std::int32_t min, std::int32_t max)
std::int32_t RNG::next_int()
{
return next_int(INT32_MIN, INT32_MAX);
return (chance() ? 1 : -1) * (std::int32_t)floor(sample() * (double)INT32_MAX);
}
std::int64_t RNG::next_long(std::int64_t min, std::int64_t max)
@ -43,5 +43,5 @@ std::int64_t RNG::next_long(std::int64_t min, std::int64_t max)
std::int64_t RNG::next_long()
{
return next_long(INT64_MIN, INT32_MAX);
return (chance() ? 1l : -1l) * (std::int64_t)floor(sample() * (double)INT64_MAX);
}

@ -10,7 +10,7 @@ namespace rng {
for(int i=0;i<10;i++) {
double d = rng.next_double();
long l = rng.next_long(0, 100);
long l = rng.next_long(-10, 10);
std::array<bool, 10> ar;
for(auto& i : ar) i = rng.chance();

Loading…
Cancel
Save