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 | /* |
---|
13 | FUNCTION |
---|
14 | <<isnan>>, <<isnanf>>, <<isinf>>, <<isinff>>, <<finite>>, <<finitef>>---test for exceptional numbers |
---|
15 | |
---|
16 | INDEX |
---|
17 | isnan |
---|
18 | INDEX |
---|
19 | isinf |
---|
20 | INDEX |
---|
21 | finite |
---|
22 | |
---|
23 | INDEX |
---|
24 | isnanf |
---|
25 | INDEX |
---|
26 | isinff |
---|
27 | INDEX |
---|
28 | finitef |
---|
29 | |
---|
30 | SYNOPSIS |
---|
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 | |
---|
40 | DESCRIPTION |
---|
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 | |
---|
72 | QUICKREF |
---|
73 | isnan - pure |
---|
74 | QUICKREF |
---|
75 | isinf - pure |
---|
76 | QUICKREF |
---|
77 | finite - pure |
---|
78 | QUICKREF |
---|
79 | isnan - pure |
---|
80 | QUICKREF |
---|
81 | isinf - pure |
---|
82 | QUICKREF |
---|
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 | |
---|
95 | int |
---|
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 */ |
---|