fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / common / s_fpclassify.c
blob2820f0373f65e776a218948dc54d7997520a4f13
1 /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
3 * Permission to use, copy, modify, and distribute this software
4 * is freely granted, provided that this notice is preserved.
5 */
7 #include "fdlibm.h"
9 int
10 __fpclassifyf (float x)
12 unsigned int w;
14 GET_FLOAT_WORD(w,x);
16 if (w == 0x00000000 || w == 0x80000000)
17 return FP_ZERO;
18 else if ((w >= 0x00800000 && w <= 0x7f7fffff) ||
19 (w >= 0x80800000 && w <= 0xff7fffff))
20 return FP_NORMAL;
21 else if ((w >= 0x00000001 && w <= 0x007fffff) ||
22 (w >= 0x80000001 && w <= 0x807fffff))
23 return FP_SUBNORMAL;
24 else if (w == 0x7f800000 || w == 0xff800000)
25 return FP_INFINITE;
26 else
27 return FP_NAN;
30 int
31 __fpclassifyd (double x)
33 unsigned int msw, lsw;
35 EXTRACT_WORDS(msw,lsw,x);
37 if ((msw == 0x00000000 && lsw == 0x00000000) ||
38 (msw == 0x80000000 && lsw == 0x00000000))
39 return FP_ZERO;
40 else if ((msw >= 0x00100000 && msw <= 0x7fefffff) ||
41 (msw >= 0x80100000 && msw <= 0xffefffff))
42 return FP_NORMAL;
43 else if ((msw >= 0x00000000 && msw <= 0x000fffff) ||
44 (msw >= 0x80000000 && msw <= 0x800fffff))
45 /* zero is already handled above */
46 return FP_SUBNORMAL;
47 else if ((msw == 0x7ff00000 && lsw == 0x00000000) ||
48 (msw == 0xfff00000 && lsw == 0x00000000))
49 return FP_INFINITE;
50 else
51 return FP_NAN;