From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/math/__fpclassify.c | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/math/__fpclassify.c (limited to 'src/math/__fpclassify.c') diff --git a/src/math/__fpclassify.c b/src/math/__fpclassify.c new file mode 100644 index 0000000..f7c0e2d --- /dev/null +++ b/src/math/__fpclassify.c @@ -0,0 +1,11 @@ +#include +#include + +int __fpclassify(double x) +{ + union {double f; uint64_t i;} u = {x}; + int e = u.i>>52 & 0x7ff; + if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO; + if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE; + return FP_NORMAL; +} -- cgit v1.2.3