summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorry755 <ryanst755@gmail.com>2020-11-16 21:27:13 -0800
committerAndreas Kling <kling@serenityos.org>2020-11-17 09:57:06 +0100
commitb1fb8e3741e680eab08ffaa3f49ed417b84c0fab (patch)
tree1c60af8232e08e046e476144053b295694e03ae9
parent7ef8835e5aa394af47f23e5e9befe416aa0efefc (diff)
downloadserenity-b1fb8e3741e680eab08ffaa3f49ed417b84c0fab.zip
LibM: Define some floating point classification macros
This adds a few macros used to determine the category of a floating point number. This fixes a build error with the jq port due to the previously missing isnormal() macro. Co-authored-by: Lua MacDougall <luawhat@gmail.com>
-rw-r--r--Libraries/LibM/math.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/Libraries/LibM/math.h b/Libraries/LibM/math.h
index 6486b842d7..8d9b727ddc 100644
--- a/Libraries/LibM/math.h
+++ b/Libraries/LibM/math.h
@@ -50,6 +50,19 @@ __BEGIN_DECLS
#define M_SQRT2 1.4142135623730951
#define M_SQRT1_2 0.7071067811865475
+#define FP_NAN 0
+#define FP_INFINITE 1
+#define FP_ZERO 2
+#define FP_SUBNORMAL 3
+#define FP_NORMAL 4
+#define fpclassify(x) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_ZERO, x)
+
+#define signbit(x) __builtin_signbit(x)
+#define isnan(x) __builtin_isnan(x)
+#define isinf(x) __builtin_isinf_sign(x)
+#define isfinite(x) __builtin_isfinite(x)
+#define isnormal(x) __builtin_isnormal(x)
+
#define DOUBLE_MAX ((double)0b0111111111101111111111111111111111111111111111111111111111111111)
#define DOUBLE_MIN ((double)0b0000000000010000000000000000000000000000000000000000000000000000)