FastLED 3.10.6
Loading...
Searching...
No Matches

◆ soft_double_bits_from_float_bits()

u64 fl::soft_double_bits_from_float_bits ( u32 bits)
inline

Definition at line 152 of file soft_float.h.

152 {
153 const u64 sign = (bits >> 31) ? 0x8000000000000000ull : 0ull;
154 const u32 exp_bits = (bits >> 23) & 0xFFu;
155 const u32 mantissa_bits = bits & 0x007FFFFFu;
156 if (exp_bits == 0xFFu) {
157 return mantissa_bits == 0 ? sign | 0x7FF0000000000000ull
158 : sign | 0x7FF8000000000000ull;
159 }
160 if (exp_bits == 0) {
161 if (mantissa_bits == 0) {
162 return sign;
163 }
164 // Subnormal float -- always a normal double. Walk the implicit bit
165 // up to position 23, adjust exponent accordingly.
166 u32 m = mantissa_bits;
167 int shift = 0;
168 while ((m & 0x00800000u) == 0) {
169 m <<= 1;
170 ++shift;
171 }
172 const int double_exp = 1 - 127 - shift + 1023;
173 const u64 mantissa_d = static_cast<u64>(m & 0x007FFFFFu) << 29;
174 return sign | (static_cast<u64>(double_exp) << 52) | mantissa_d;
175 }
176 const int double_exp = static_cast<int>(exp_bits) - 127 + 1023;
177 const u64 mantissa_d = static_cast<u64>(mantissa_bits) << 29;
178 return sign | (static_cast<u64>(double_exp) << 52) | mantissa_d;
179}
constexpr enable_if< is_fixed_point< T >::value, int >::type sign(T x) FL_NO_EXCEPT
fl::u64 u64
Definition stdint.h:220

References FL_NO_EXCEPT, and sign().

Referenced by fl::detail::json_ieee754_double_bits_from_float_bits(), and soft_float_to_double().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: