More efficient implementation of frandom() in stdlib

This commit is contained in:
Matt Pharr
2011-08-03 14:28:06 +01:00
parent 7d7dd2b204
commit a2996ed5d9
3 changed files with 47 additions and 1 deletions

View File

@@ -2624,7 +2624,9 @@ static inline unsigned int random(reference RNGState state)
static inline float frandom(reference RNGState state)
{
return ((int)(random(state) & ((1<<24)-1))) / (float)(1 << 24);
unsigned int irand = random(state);
irand &= (1<<23)-1;
return floatbits(0x3F800000 | irand)-1.0f;
}
static inline uniform unsigned int __seed4(reference RNGState state,