source: trunk/libs/newlib/src/newlib/libm/common/s_isnand.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.2 KB
Line 
1/*
2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
4 *
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
8 * is preserved.
9 * ====================================================
10 */
11
12/*
13FUNCTION
14        <<isnan>>, <<isnanf>>, <<isinf>>, <<isinff>>, <<finite>>, <<finitef>>---test for exceptional numbers
15
16INDEX
17        isnan
18INDEX
19        isinf
20INDEX
21        finite
22
23INDEX
24        isnanf
25INDEX
26        isinff
27INDEX
28        finitef
29
30SYNOPSIS
31        #include <math.h>
32        int isnan(double <[arg]>);
33        int isinf(double <[arg]>);
34        int finite(double <[arg]>);
35        int isnanf(float <[arg]>);
36        int isinff(float <[arg]>);
37        int finitef(float <[arg]>);
38
39
40DESCRIPTION
41        These functions provide information on the floating-point
42        argument supplied.
43
44        There are five major number formats:
45        o+
46        o zero
47          A number which contains all zero bits.
48        o subnormal
49          A number with a zero exponent but a nonzero fraction.
50        o normal
51          A number with an exponent and a fraction.
52        o infinity
53          A number with an all 1's exponent and a zero fraction.
54        o NAN
55          A number with an all 1's exponent and a nonzero fraction.
56
57        o-
58
59        <<isnan>> returns 1 if the argument is a nan. <<isinf>>
60        returns 1 if the argument is infinity.  <<finite>> returns 1 if the
61        argument is zero, subnormal or normal.
62
63        Note that by the C99 standard, <<isnan>> and <<isinf>> are macros
64        taking any type of floating-point and are declared in
65        <<math.h>>.  Newlib has chosen to declare these both as functions
66        and as macros in <<math.h>>.
67       
68        The <<isnanf>>, <<isinff>> and <<finitef>> functions perform the same
69        operations as their <<isnan>>, <<isinf>> and <<finite>>
70        counterparts, but on single-precision floating-point numbers.
71
72QUICKREF
73        isnan - pure
74QUICKREF
75        isinf - pure
76QUICKREF
77        finite - pure
78QUICKREF
79        isnan - pure
80QUICKREF
81        isinf - pure
82QUICKREF
83        finite - pure
84*/
85
86/*
87 * __isnand(x) returns 1 is x is nan, else 0;
88 * no branching!
89 */
90
91#include "fdlibm.h"
92
93#ifndef _DOUBLE_IS_32BITS
94
95int
96__isnand (double x)
97{
98        __int32_t hx,lx;
99        EXTRACT_WORDS(hx,lx,x);
100        hx &= 0x7fffffff;
101        hx |= (__uint32_t)(lx|(-lx))>>31;       
102        hx = 0x7ff00000 - hx;
103        return (int)(((__uint32_t)(hx))>>31);
104}
105
106#endif /* _DOUBLE_IS_32BITS */
Note: See TracBrowser for help on using the repository browser.