/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1994-1997, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "quad.h"
#ifdef __sparcv9
/*
* _Qp_dtoq(pz, x) sets *pz = (long double)x.
*/
void
#else
/*
* _Q_dtoq(x) returns (long double)x.
*/
union longdouble
_Q_dtoq(double x)
#endif /* __sparcv9 */
{
#ifndef __sparcv9
union longdouble z;
#endif
union xdouble u;
/* extract the exponent */
u.d = x;
if (m == 0x3c000000) {
/* x is zero or denormal */
/* x is denormal, normalize it */
m = 0x3c010000;
do {
llo <<= 1;
m -= 0x10000;
} while ((lhi & 0x7ff00000) == 0);
} else {
m = 0;
}
} else if (m == 0x43ff0000) {
/* x is inf or nan */
m = 0x7fff0000;
/* snan, signal invalid */
__quad_fdtoq(&x, &Z);
QUAD_RETURN(Z);
} else {
}
u.l.hi |= 0x80000;
}
}
Z.l.frac4 = 0;
QUAD_RETURN(Z);
}