| 140 | } |
| 141 | |
| 142 | float |
| 143 | Rand32::nextf () |
| 144 | { |
| 145 | // |
| 146 | // Generate single-precision floating-point values between 0.0 and 1.0: |
| 147 | // |
| 148 | // The exponent is set to 0x7f, which indicates a value greater than |
| 149 | // or equal to 1.0, and less than 2.0. The 23 bits of the significand |
| 150 | // (mantissa) are filled with pseudo-random bits generated by |
| 151 | // Rand32::next(). This results in in bit patterns between 0x3f800000 |
| 152 | // and 0x3fffffff, which correspond to uniformly distributed floating- |
| 153 | // point values between 1.0 and 1.99999988. Subtracting 1.0 from |
| 154 | // those values produces numbers between 0.0 and 0.99999988, that is, |
| 155 | // between 0.0 and 1.0-FLT_EPSILON. |
| 156 | // |
| 157 | |
| 158 | next (); |
| 159 | |
| 160 | union |
| 161 | { |
| 162 | float f; |
| 163 | unsigned int i; |
| 164 | } u; |
| 165 | |
| 166 | u.i = 0x3f800000 | (_state & 0x7fffff); |
| 167 | return u.f - 1; |
| 168 | } |
| 169 | |
| 170 | IMATH_INTERNAL_NAMESPACE_SOURCE_EXIT |
nothing calls this directly
no outgoing calls
no test coverage detected