[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483,...
[glibc.git] / sysdeps / ieee754 / ldbl-128ibm / s_fpclassifyl.c
blob3ca178a3c518d4d59222556b77dd3beb0fb934dd
1 /* Return classification value corresponding to argument.
2 Copyright (C) 1997,1999,2002,2004,2006 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
34 * -0 8000 0000 0000 0000
35 * +normal 001n nnnn nnnn nnnn (smallest)
36 * -normal 801n nnnn nnnn nnnn (smallest)
37 * +normal 7fen nnnn nnnn nnnn (largest)
38 * -normal ffen nnnn nnnn nnnn (largest)
39 * +denorm 000n nnnn nnnn nnnn
40 * -denorm 800n nnnn nnnn nnnn
43 int
44 ___fpclassifyl (long double x)
46 u_int64_t hx, lx;
47 int retval = FP_NORMAL;
49 GET_LDOUBLE_WORDS64 (hx, lx, x);
50 if ((hx & 0x7ff0000000000000ULL) == 0x7ff0000000000000ULL) {
51 /* +/-NaN or +/-Inf */
52 if (hx & 0x000fffffffffffffULL) {
53 /* +/-NaN */
54 retval = FP_NAN;
55 } else {
56 retval = FP_INFINITE;
58 } else {
59 /* +/-zero or +/- normal or +/- denormal */
60 if (hx & 0x7fffffffffffffffULL) {
61 /* +/- normal or +/- denormal */
62 if ((hx & 0x7ff0000000000000ULL) >= 0x0360000000000000ULL) {
63 /* +/- normal */
64 retval = FP_NORMAL;
65 } else {
66 /* +/- denormal */
67 retval = FP_SUBNORMAL;
69 } else {
70 /* +/- zero */
71 retval = FP_ZERO;
75 return retval;
77 long_double_symbol (libm, ___fpclassifyl, __fpclassifyl);
78 #ifdef __LONG_DOUBLE_MATH_OPTIONAL
79 libm_hidden_ver (___fpclassifyl, __fpclassifyl)
80 #else
81 libm_hidden_def (__fpclassifyl)
82 #endif