From: Alan Cox Date: Mon, 5 Mar 2018 20:24:48 +0000 (+0000) Subject: fpclassify: rewrite in terms of macros X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=286e41a0c9281c1728c482225dcbc28df51f4dee;p=FUZIX.git fpclassify: rewrite in terms of macros --- 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; }