From 286e41a0c9281c1728c482225dcbc28df51f4dee Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 5 Mar 2018 20:24:48 +0000 Subject: [PATCH] fpclassify: rewrite in terms of macros --- Library/libs/__fpclassify.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Library/libs/__fpclassify.c b/Library/libs/__fpclassify.c index 7c08ef3b..4d00c6ce 100644 --- a/Library/libs/__fpclassify.c +++ b/Library/libs/__fpclassify.c @@ -3,9 +3,19 @@ int __fpclassify(double x) { - union dshape u = { x }; - int e = u.bits>>52 & 0x7ff; - if (!e) return u.bits<<1 ? FP_SUBNORMAL : FP_ZERO; - if (e==0x7ff) return u.bits<<12 ? FP_NAN : FP_INFINITE; + uint32_t lo,hi; + EXTRACT_WORDS(hi,lo,x); + + int e = hi>>7 & 0x7ff; + if (!e) { + if (lo == 0 && (hi << 1) == 0) + return FP_ZERO; + return FP_SUBNORMAL; + } + if (e==0x7ff) { + if (lo || hi & 0x000FFFFF) + return FP_NAN; + return FP_INFINITE; + } return FP_NORMAL; } -- 2.34.1