diff options
author | Dan Klishch <danilklishch@gmail.com> | 2022-10-28 12:02:03 -0400 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-11-03 20:17:09 -0600 |
commit | 17c9a3e8d951420bd85f7445c829bc6fbde4ade2 (patch) | |
tree | 7aa8e32fa84009b03b000d9b2529468f52fa5e2e /Userland/Libraries/LibC/math.cpp | |
parent | 2d75229192f780fa4df845add4dcee37f6caa0ce (diff) | |
download | serenity-17c9a3e8d951420bd85f7445c829bc6fbde4ade2.zip |
AK+LibC+LibCrypto: Move FloatExtractor to AK/FloatingPoint.h
Diffstat (limited to 'Userland/Libraries/LibC/math.cpp')
-rw-r--r-- | Userland/Libraries/LibC/math.cpp | 52 |
1 files changed, 1 insertions, 51 deletions
diff --git a/Userland/Libraries/LibC/math.cpp b/Userland/Libraries/LibC/math.cpp index db83bc508c..520a27cc16 100644 --- a/Userland/Libraries/LibC/math.cpp +++ b/Userland/Libraries/LibC/math.cpp @@ -9,6 +9,7 @@ #include <AK/BuiltinWrappers.h> #include <AK/ExtraMathConstants.h> +#include <AK/FloatingPoint.h> #ifndef AK_ARCH_AARCH64 # include <AK/FPControl.h> #endif @@ -61,57 +62,6 @@ enum class RoundingMode { ToEven = FE_TONEAREST }; -template<typename T> -union FloatExtractor; - -#if ARCH(I386) || ARCH(X86_64) || ARCH(AARCH64) -// This assumes long double is 80 bits, which is true with GCC on Intel platforms -template<> -union FloatExtractor<long double> { - static constexpr int mantissa_bits = 64; - static constexpr unsigned long long mantissa_max = ~0u; - static constexpr int exponent_bias = 16383; - static constexpr int exponent_bits = 15; - static constexpr unsigned exponent_max = 32767; - struct { - unsigned long long mantissa; - unsigned exponent : 15; - unsigned sign : 1; - }; - long double d; -}; -#endif - -template<> -union FloatExtractor<double> { - static constexpr int mantissa_bits = 52; - static constexpr unsigned long long mantissa_max = (1ull << 52) - 1; - static constexpr int exponent_bias = 1023; - static constexpr int exponent_bits = 11; - static constexpr unsigned exponent_max = 2047; - struct { - unsigned long long mantissa : 52; - unsigned exponent : 11; - unsigned sign : 1; - }; - double d; -}; - -template<> -union FloatExtractor<float> { - static constexpr int mantissa_bits = 23; - static constexpr unsigned mantissa_max = (1 << 23) - 1; - static constexpr int exponent_bias = 127; - static constexpr int exponent_bits = 8; - static constexpr unsigned exponent_max = 255; - struct { - unsigned long long mantissa : 23; - unsigned exponent : 8; - unsigned sign : 1; - }; - float d; -}; - // This is much branchier than it really needs to be template<typename FloatType> static FloatType internal_to_integer(FloatType x, RoundingMode rounding_mode) |