Improved floating point random number generation.

Fixed loading RGB images, as reported in issue 15.
Moved pixel format conversion helpers to PixelFormat.h
This commit is contained in:
castano
2007-10-08 00:56:58 +00:00
parent c9c7c42d2b
commit e7aca55ba3
5 changed files with 131 additions and 91 deletions

View File

@ -35,6 +35,20 @@ public:
return n;
}
/// Random number on [0.0, 1.0] interval.
float getFloat()
{
union
{
uint32 i;
float f;
} pun;
pun.i = 0x3f800000UL | (get() & 0x007fffffUL);
return pun.f - 1.0f;
}
/*
/// Random number on [0.0, 1.0] interval.
double getReal()
{
@ -45,7 +59,8 @@ public:
double getRealExclusive()
{
return double(get()) * (1.0/4294967296.0); // 2^32
}
}
*/
/// Get the max value of the random number.
uint max() const { return 4294967295U; }
@ -301,7 +316,7 @@ public:
}
/** Get a random number. */
virtual uint Get() {
virtual uint get() {
advance();