/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "lint.h"
#include "base_conversion.h"
/* conversion from hex chars to hex values */
10 + (('a' <= c && c <= 'f')? c - 'a' : c - 'A'))
/*
* Convert a hexadecimal record in *pd to unpacked form in *pu.
*
* Up to 30 hexadecimal digits from pd->ds are converted to a binary
* value in px->significand, which is then normalized so that the most
* significant bit is 1. If there are additional, unused digits in
* pd->ds, the least significant bit of px->significand will be set.
*/
static void
{
int i, n;
/*
* Adjust the (base two) exponent to reflect the fact that the
* radix point in *pd lies to the right of the last (base sixteen)
* digit while the radix point in *pu lies to the right of the
* most significant bit.
*/
/* fill in the significand */
for (i = 0; i < 5; i++)
pu->significand[i] = 0;
if (n > 30)
n = 30;
for (i = 0; i < n; i++) {
((7 - (i & 7)) << 2);
}
/* sanity check */
if (pu->significand[0] == 0) {
return;
}
/* normalize so the most significant bit is set */
}
/* if there are any unused digits, set a sticky bit */
}
/*
* The following routines convert the hexadecimal value encoded in the
* decimal record *pd to a floating point value *px observing the round-
* ing mode specified in rd and passing back any exceptions raised via
* *ps.
*
* These routines assume pd->fpclass is either fp_zero or fp_normal.
* If pd->fpclass is fp_zero, *px is set to zero with the sign indicated
* by pd->sign and no exceptions are raised. Otherwise, pd->ds must
* contain a string of hexadecimal digits of length pd->ndigits > 0, and
* the first digit must be nonzero. Let m be the integer represented by
* this string. Then *px is set to a correctly rounded approximation to
*
* (-1)^(pd->sign) * m * 2^(pd->exponent)
*
*/
void
{
unpacked u;
*ps = 0;
} else {
__hex_to_unpacked(pd, &u);
if (*ps != 0)
}
}
void
{
unpacked u;
*ps = 0;
kluge.f.significand2 = 0;
} else {
__hex_to_unpacked(pd, &u);
if (*ps != 0)
}
}
#if defined(__sparc)
void
{
unpacked u;
*ps = 0;
kluge.f.significand2 = 0;
kluge.f.significand3 = 0;
kluge.f.significand4 = 0;
} else {
__hex_to_unpacked(pd, &u);
if (*ps != 0)
}
}
void
{
unpacked u;
*ps = 0;
kluge.f.significand = 0;
kluge.f.significand2 = 0;
} else {
__hex_to_unpacked(pd, &u);
if (*ps != 0)
}
}
#else
#endif