Browse Source

Fix random::uniform() to not return 1.f.

tags/v1.1.6
Andrew Belt 2 years ago
parent
commit
5c5f3f4517
1 changed files with 1 additions and 2 deletions
  1. +1
    -2
      src/random.cpp

+ 1
- 2
src/random.cpp View File

@@ -49,8 +49,7 @@ uint64_t u64() {
}

float uniform() {
// 24 bits of granularity is the best that can be done with floats while ensuring that the return value lies in [0.0, 1.0).
return xoroshiro128plus_next() / std::pow(2.f, 64);
return (xoroshiro128plus_next() >> (64 - 24)) / std::pow(2.f, 24);
}

float normal() {


Loading…
Cancel
Save