diff --git a/Userland/Libraries/LibM/math.cpp b/Userland/Libraries/LibM/math.cpp index 47ab3e537c..8a7a0f15c3 100644 --- a/Userland/Libraries/LibM/math.cpp +++ b/Userland/Libraries/LibM/math.cpp @@ -24,6 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include #include #include #include @@ -67,6 +69,24 @@ enum class RoundingMode { template union FloatExtractor; +#if ARCH(I386) || ARCH(X86_64) +// This assumes long double is 80 bits, which is true with GCC on Intel platforms +template<> +union FloatExtractor { + static const int mantissa_bits = 64; + static const unsigned long long mantissa_max = ~0u; + static const int exponent_bias = 16383; + static const int exponent_bits = 15; + static const unsigned exponent_max = 32767; + struct { + unsigned long long mantissa; + unsigned exponent : 15; + unsigned sign : 1; + }; + long double d; +}; +#endif + template<> union FloatExtractor { static const int mantissa_bits = 52;