_sprintf_sup.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 1988 by Sun Microsystems, Inc.
*/
#include "base_conversion.h"
/*
* Fundamental utilities of base conversion required for sprintf - but too
* complex or too seldom used to be worth assembly language coding.
*/
unsigned long
_prodc_b10000(x, y, c) /* p = x * y + c ; return (p/10000 << 16 |
* p%10000) */
_BIG_FLOAT_DIGIT x, y;
unsigned long c;
{
unsigned long p = x * (unsigned long) y + c;
return ((p / 10000) << 16) | (p % 10000);
}
unsigned long
_prod_b65536(x, y) /* p = x * y ; return p */
_BIG_FLOAT_DIGIT x, y;
{
return x * (unsigned long) y;
}
unsigned long
_prod_b10000(x, y) /* p = x * y ; return (p/10000 << 16 |
* p%10000) */
_BIG_FLOAT_DIGIT x, y;
{
unsigned long p = x * (unsigned long) y;
return ((p / 10000) << 16) | (p % 10000);
}
unsigned long
_lshift_b10000(x, n, c) /* p = x << n + c ; return (p/10000 << 16 |
* p%10000) */
short unsigned n;
long unsigned c;
{
unsigned long p = (((unsigned long) x) << n) + c;
return ((p / 10000) << 16) | (p % 10000);
}
unsigned long
_prod_10000_b65536(x, c) /* p = x * 10000 + c ; return p */
long unsigned c;
{
return x * (unsigned long) 10000 + c;
}
unsigned long
_prod_65536_b10000(x, c) /* p = x << 16 + c ; return (p/10000 << 16 |
* p%10000) */
long unsigned c;
{
unsigned long p = (((unsigned long) x) << 16) + c;
return ((p / 10000) << 16) | (p % 10000);
}
unsigned long
_carry_out_b10000(c) /* p = c ; return (p/10000 << 16 | p%10000) */
unsigned long c;
{
return ((c / 10000) << 16) | (c % 10000);
}
void
short unsigned multiplier;
{
/*
* Multiply a base-10**4 significand by 2<<multiplier. Extend length
* as necessary to accommodate carries.
*/
int j;
unsigned long carry;
long p;
carry = 0;
for (j = 0; j < length; j++) {
carry = p >> 16;
}
while (carry != 0) {
p = _carry_out_b10000(carry);
carry = p >> 16;
}
}
void
short unsigned multiplier;
{
/*
* Multiply a base-2**16 significand by 2<<multiplier. Extend length
* as necessary to accommodate carries.
*/
long unsigned p;
int j;
unsigned long carry;
carry = 0;
for (j = 0; j < length; j++) {
carry = p >> 16;
}
if (carry != 0) {
}
}
void
short unsigned multiplier;
{
/* *pb = *pb / 2**multiplier to normalize. 15 <= multiplier <= 1 */
/* Any bits shifted out got to *sticky. */
long unsigned p;
int j;
unsigned long carry;
carry = 0;
carry = p & 0xffff;
}
}
void
{
/*
* Multiply a base-10**4 significand by multiplier. Extend length as
* necessary to accommodate carries.
*/
int j;
unsigned long carry;
long p;
carry = 0;
carry = p >> 16;
}
while (carry != 0) {
p = _carry_out_b10000(carry);
carry = p >> 16;
}
}
void
long unsigned carry;
{
/*
* Multiply a base-2**16 significand by multiplier. Extend length as
* necessary to accommodate carries.
*/
long unsigned p;
int j;
for (j = 0; j < length; j++) {
carry = p >> 16;
}
if (carry != 0) {
}
}
void
short unsigned multiplier;
{
/*
* Multiply a base-10**4 significand by 2**multiplier. Extend length
* as necessary to accommodate carries.
*/
int j;
long unsigned carry, p;
carry = 0;
for (j = 0; j < length; j++) {
carry = p >> 16;
}
while (carry != 0) {
p = _carry_out_b10000(carry);
carry = p >> 16;
}
}
void
_big_float *pb;
int *pe;
{
/*
* Converts pu into a bigfloat *pb of minimal length; exponent *pe
* such that pu = *pb * 2 ** *pe
*/
}
if (pb->bsignificand[0] == 0) {
}
#ifdef DEBUG
#endif
}
void
unsigned long carry;
{
/* *pbf *= 65536 ; += carry ; */
long unsigned p;
int j;
carry = p >> 16;
}
while (carry != 0) {
p = _carry_out_b10000(carry);
carry = p >> 16;
}
}
void
{
/* Convert _big_float from binary form to decimal form. */
int i;
} else {
}
* add next significand. */
}
* each trailing zero. */
_mul_65536short(pd, (unsigned long) 0);
}
#ifdef DEBUG
printf(" _big_binary_to_big_decimal ");
#endif
}