| 2087 | }; |
| 2088 | |
| 2089 | TOML_PURE_GETTER |
| 2090 | inline fp_class fpclassify(const double& val) noexcept |
| 2091 | { |
| 2092 | static_assert(sizeof(uint64_t) == sizeof(double)); |
| 2093 | |
| 2094 | static constexpr uint64_t sign = 0b1000000000000000000000000000000000000000000000000000000000000000ull; |
| 2095 | static constexpr uint64_t exponent = 0b0111111111110000000000000000000000000000000000000000000000000000ull; |
| 2096 | static constexpr uint64_t mantissa = 0b0000000000001111111111111111111111111111111111111111111111111111ull; |
| 2097 | |
| 2098 | uint64_t val_bits; |
| 2099 | std::memcpy(&val_bits, &val, sizeof(val)); |
| 2100 | if ((val_bits & exponent) != exponent) |
| 2101 | return fp_class::ok; |
| 2102 | if ((val_bits & mantissa)) |
| 2103 | return fp_class::nan; |
| 2104 | return (val_bits & sign) ? fp_class::neg_inf : fp_class::pos_inf; |
| 2105 | } |
| 2106 | |
| 2107 | // Q: "why not use std::find and std::min?" |
| 2108 | // A: Because <algorithm> is _huge_ and these would be the only things I used from it. |
no outgoing calls
no test coverage detected