Improved the numeric distribution of love.math.random.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-05-15 10:25:08 -03:00
parent 31b44797bc
commit 8b920ba816
+7 -1
View File
@@ -73,7 +73,13 @@ public:
**/
inline double random()
{
return double(rand()) / (double(std::numeric_limits<uint64>::max()) + 1.0);
uint64 r = rand();
// From http://xoroshiro.di.unimi.it
union { uint64 i; double d; } u;
u.i = ((0x3FFULL) << 52) | (r >> 12);
return u.d - 1.0;
}
/**