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]
23 * Copyright (c) 1994-1997, by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
34 * _Qp_dtoq(pz, x) sets *pz = (long double)x.
37 _Qp_dtoq(union longdouble
*pz
, double x
)
42 * _Q_dtoq(x) returns (long double)x.
47 #endif /* __sparcv9 */
54 unsigned int m
, lhi
, llo
, fsr
;
56 /* extract the exponent */
58 m
= ((u
.l
.hi
& 0x7ff00000) >> 4) + 0x3c000000;
59 if (m
== 0x3c000000) {
60 /* x is zero or denormal */
61 if ((u
.l
.hi
& 0xfffff) | u
.l
.lo
) {
62 /* x is denormal, normalize it */
64 lhi
= u
.l
.hi
& 0xfffff;
67 lhi
= (lhi
<< 1) | (llo
>> 31);
70 } while ((lhi
& 0x7ff00000) == 0);
71 u
.l
.hi
= (u
.l
.hi
& 0x80000000) | lhi
;
76 } else if (m
== 0x43ff0000) {
79 if (((u
.l
.hi
& 0x7ffff) | u
.l
.lo
) && (u
.l
.hi
& 0x80000) == 0) {
80 /* snan, signal invalid */
86 fsr
= (fsr
& ~FSR_CEXC
) | FSR_NVA
| FSR_NVC
;
92 Z
.l
.msw
= m
| (u
.l
.hi
& 0x80000000) | ((u
.l
.hi
& 0xffff0) >> 4);
93 Z
.l
.frac2
= (u
.l
.hi
<< 28) | (u
.l
.lo
>> 4);
94 Z
.l
.frac3
= u
.l
.lo
<< 28;