2.9
[glibc/nacl-glibc.git] / sysdeps / ieee754 / ldbl-128ibm / s_fpclassifyl.c
blob6999abc2509b35eaad6a160b671b232e561f20c2
1 /* Return classification value corresponding to argument.
2 Copyright (C) 1997,1999,2002,2004,2006,2007 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
5 Jakub Jelinek <jj@ultra.linux.cz>, 1999.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA. */
22 #include <math.h>
24 #include "math_private.h"
25 #include <math_ldbl_opt.h>
28 * hx lx
29 * +NaN 7ffn nnnn nnnn nnnn xxxx xxxx xxxx xxxx
30 * -NaN fffn nnnn nnnn nnnn xxxx xxxx xxxx xxxx
31 * +Inf 7ff0 0000 0000 0000 xxxx xxxx xxxx xxxx
32 * -Inf fff0 0000 0000 0000 xxxx xxxx xxxx xxxx
33 * +0 0000 0000 0000 0000 xxxx xxxx xxxx xxxx
34 * -0 8000 0000 0000 0000 xxxx xxxx xxxx xxxx
35 * +normal 0360 0000 0000 0000 0000 0000 0000 0000 (smallest)
36 * -normal 8360 0000 0000 0000 0000 0000 0000 0000 (smallest)
37 * +normal 7fef ffff ffff ffff 7c8f ffff ffff fffe (largest)
38 * +normal ffef ffff ffff ffff fc8f ffff ffff fffe (largest)
39 * +denorm 0360 0000 0000 0000 8000 0000 0000 0001 (largest)
40 * -denorm 8360 0000 0000 0000 0000 0000 0000 0001 (largest)
41 * +denorm 000n nnnn nnnn nnnn xxxx xxxx xxxx xxxx
42 * -denorm 800n nnnn nnnn nnnn xxxx xxxx xxxx xxxx
45 int
46 ___fpclassifyl (long double x)
48 u_int64_t hx, lx;
49 int retval = FP_NORMAL;
51 GET_LDOUBLE_WORDS64 (hx, lx, x);
52 if ((hx & 0x7ff0000000000000ULL) == 0x7ff0000000000000ULL) {
53 /* +/-NaN or +/-Inf */
54 if (hx & 0x000fffffffffffffULL) {
55 /* +/-NaN */
56 retval = FP_NAN;
57 } else {
58 retval = FP_INFINITE;
60 } else {
61 /* +/-zero or +/- normal or +/- denormal */
62 if (hx & 0x7fffffffffffffffULL) {
63 /* +/- normal or +/- denormal */
64 if ((hx & 0x7ff0000000000000ULL) > 0x0360000000000000ULL) {
65 /* +/- normal */
66 retval = FP_NORMAL;
67 } else {
68 if ((hx & 0x7ff0000000000000ULL) == 0x0360000000000000ULL) {
69 if ((lx & 0x7fffffffffffffff) /* lower is non-zero */
70 && ((lx^hx) & 0x8000000000000000ULL)) { /* and sign differs */
71 /* +/- denormal */
72 retval = FP_SUBNORMAL;
73 } else {
74 /* +/- normal */
75 retval = FP_NORMAL;
77 } else {
78 /* +/- denormal */
79 retval = FP_SUBNORMAL;
82 } else {
83 /* +/- zero */
84 retval = FP_ZERO;
88 return retval;
90 long_double_symbol (libm, ___fpclassifyl, __fpclassifyl);
91 #ifdef __LONG_DOUBLE_MATH_OPTIONAL
92 libm_hidden_ver (___fpclassifyl, __fpclassifyl)
93 #else
94 libm_hidden_def (__fpclassifyl)
95 #endif