From b1fb8e3741e680eab08ffaa3f49ed417b84c0fab Mon Sep 17 00:00:00 2001 From: ry755 Date: Mon, 16 Nov 2020 21:27:13 -0800 Subject: [PATCH] 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 --- Libraries/LibM/math.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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)