4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 #pragma ident "%Z%%M% %I% %E% SMI"
25 * Copyright (c) 1988 by Sun Microsystems, Inc.
29 #include "_Qglobals.h"
32 _fp_compare(px
, py
, strict
)
34 int strict
; /* 0 if quiet NaN unexceptional, 1 if
41 if ((px
->fpclass
== fp_quiet
) || (py
->fpclass
== fp_quiet
) ||
42 (px
->fpclass
== fp_signaling
) || (py
->fpclass
== fp_signaling
)) {
44 fpu_set_exception(fp_invalid
);
46 } else if ((px
->fpclass
== fp_zero
) && (py
->fpclass
== fp_zero
))
49 else if (px
->sign
< py
->sign
)
51 else if (px
->sign
> py
->sign
)
53 else { /* signs the same, compute magnitude cc */
54 if ((int) px
->fpclass
> (int) py
->fpclass
)
56 else if ((int) px
->fpclass
< (int) py
->fpclass
)
59 /* same classes */ if (px
->fpclass
== fp_infinity
)
60 cc
= fcc_equal
; /* same infinity */
61 else if (px
->exponent
> py
->exponent
)
63 else if (px
->exponent
< py
->exponent
)
65 else { /* equal exponents */
66 n
= fpu_cmpli(px
->significand
,py
->significand
,4);
67 if(n
>0) cc
= fcc_greater
;
68 else if(n
<0) cc
= fcc_less
;
72 switch (cc
) { /* negative numbers */