mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
Improved the numeric distribution of love.math.random.
--HG-- branch : minor
This commit is contained in:
@@ -73,7 +73,13 @@ public:
|
|||||||
**/
|
**/
|
||||||
inline double random()
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user