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 1988 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "base_conversion.h"
31 /* The following should be coded as inline expansion templates. */
34 * Fundamental utilities that multiply two shorts into a unsigned long, add
35 * carry, compute quotient and remainder in underlying base, and return
36 * quo<<16 | rem as a unsigned long.
40 * C compilers tend to generate bad code - forcing full unsigned long by
41 * unsigned long multiplies when what is really wanted is the unsigned long
42 * product of half-long operands. Similarly the quotient and remainder are
43 * all half-long. So these functions should really be implemented by inline
44 * expansion templates.
47 /* p = x * y + c ; return p */
49 _umac(_BIG_FLOAT_DIGIT x
, _BIG_FLOAT_DIGIT y
, unsigned long c
)
51 return (x
* (unsigned long) y
+ c
);
54 /* p = x + c ; return (p/10000 << 16 | p%10000) */
56 _carry_in_b10000(_BIG_FLOAT_DIGIT x
, long unsigned c
)
58 unsigned long p
= x
+ c
;
60 return ((p
/ 10000) << 16) | (p
% 10000);
64 _carry_propagate_two(unsigned long carry
, _BIG_FLOAT_DIGIT
*psignificand
)
67 * Propagate carries in a base-2**16 significand.
75 p
= _carry_in_b65536(psignificand
[j
],carry
);
76 psignificand
[j
++] = (_BIG_FLOAT_DIGIT
) (p
& 0xffff);
82 _carry_propagate_ten(unsigned long carry
, _BIG_FLOAT_DIGIT
*psignificand
)
85 * Propagate carries in a base-10**4 significand.
93 p
= _carry_in_b10000(psignificand
[j
],carry
);
94 psignificand
[j
++] = (_BIG_FLOAT_DIGIT
) (p
& 0xffff);