summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibM
diff options
context:
space:
mode:
authorMițca Dumitru <dumitru0mitca@gmail.com>2021-03-07 20:36:08 +0200
committerAndreas Kling <kling@serenityos.org>2021-03-09 07:28:06 +0100
commit190952675e1f0d4520a8e5987fefeb1a593f519a (patch)
treedf0e33acd46bb751282da92fcbea815a23bdfd9a /Userland/Libraries/LibM
parenta13f2b7df34f890911e6e3044a55984af139b4f0 (diff)
downloadserenity-190952675e1f0d4520a8e5987fefeb1a593f519a.zip
LibM: Specialiase FloatExtractor for long double as well
Diffstat (limited to 'Userland/Libraries/LibM')
-rw-r--r--Userland/Libraries/LibM/math.cpp20
1 files changed, 20 insertions, 0 deletions
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 <AK/Platform.h>
+#include <AK/StdLibExtras.h>
#include <LibC/assert.h>
#include <math.h>
#include <stdint.h>
@@ -67,6 +69,24 @@ enum class RoundingMode {
template<typename T>
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<long double> {
+ 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<double> {
static const int mantissa_bits = 52;