4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 /* IEEE recommended functions */
34 #pragma weak _finite = finite
35 #pragma weak _fpclass = fpclass
36 #pragma weak _unordered = unordered
42 #define P754_NOFAULT 1 /* avoid generating extra code */
47 * finite(x) returns 1 if x > -inf and x < +inf and 0 otherwise
54 return ((EXPONENT(x
) != MAXEXP
));
59 * unordered(x,y) returns 1 if x is unordered with y, otherwise
60 * it returns 0; x is unordered with y if either x or y is NAN
64 unordered(double x
, double y
)
66 if ((EXPONENT(x
) == MAXEXP
) && (HIFRACTION(x
) || LOFRACTION(x
)))
68 if ((EXPONENT(y
) == MAXEXP
) && (HIFRACTION(y
) || LOFRACTION(y
)))
75 * fpclass(x) returns the floating point class x belongs to
85 if (exp
== 0) { /* de-normal or zero */
86 if (HIFRACTION(x
) || LOFRACTION(x
)) /* de-normal */
87 return (sign
? FP_NDENORM
: FP_PDENORM
);
89 return (sign
? FP_NZERO
: FP_PZERO
);
91 if (exp
== MAXEXP
) { /* infinity or NaN */
92 if ((HIFRACTION(x
) == 0) && (LOFRACTION(x
) == 0)) /* infinity */
93 return (sign
? FP_NINF
: FP_PINF
);
96 /* hi-bit of mantissa set - quiet nan */
98 else return (FP_SNAN
);
100 /* if we reach here we have non-zero normalized number */
101 return (sign
? FP_NNORM
: FP_PNORM
);