Merge pull request #2144 from smoogipoo/fix-fastrandom-inaccuracy

Fix FastRandom using uint instead of int for NextDouble()
This commit is contained in:
Dean Herbert 2018-03-01 21:33:08 +09:00 committed by GitHub
commit 71671833b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mania.MathUtils
/// </summary>
internal class FastRandom
{
private const double uint_to_real = 1.0 / (uint.MaxValue + 1.0);
private const double int_to_real = 1.0 / (int.MaxValue + 1.0);
private const uint int_mask = 0x7FFFFFFF;
private const uint y = 842502087;
private const uint z = 3579807591;
@ -65,7 +65,7 @@ public uint NextUInt()
/// Generates a random double value within the range [0, 1).
/// </summary>
/// <returns>The random value.</returns>
public double NextDouble() => uint_to_real * NextUInt();
public double NextDouble() => int_to_real * Next();
private uint bitBuffer;
private int bitIndex = 32;