| 2147 | } |
| 2148 | |
| 2149 | inline void unpack(float p, int& e_unbiased, uint32_t& mant) |
| 2150 | { |
| 2151 | // kill any denorms |
| 2152 | if (p < FLT_MIN) |
| 2153 | p = 0; |
| 2154 | |
| 2155 | union { float f; uint32_t u; } x; |
| 2156 | x.f = p; |
| 2157 | e_unbiased = int((x.u >> 23) & 0xFF) - 127; |
| 2158 | mant = (x.u & 0x7FFFFFu); // 23-bit mantissa |
| 2159 | } |
| 2160 | |
| 2161 | // Returns estimated bits given probability p, approximates -log2f(p). |
| 2162 | inline float bits_from_prob_linear(float p) |
no outgoing calls
no test coverage detected