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 /* Fundamental utilities for base conversion that should be recoded as assembly language subprograms or as inline expansion templates. */
33 /* Converts t < 10000 into four ascii digits at *pc. */
35 _fourdigitsquick(short unsigned t
, char *d
)
48 _multiply_base_two_vector(short unsigned n
, _BIG_FLOAT_DIGIT
*px
,
49 short unsigned *py
, _BIG_FLOAT_DIGIT product
[3])
52 * Given xi and yi, base 2**16 vectors of length n, computes dot
55 * sum (i=0,n-1) of x[i]*y[n-1-i]
57 * Product may fill as many as three short-unsigned buckets. Product[0]
58 * is least significant, product[2] most.
67 for (i
= 0; i
< n
; i
++) {
68 p
=_umac(px
[i
],py
[n
- 1 - i
],acc
);
73 product
[0] = (_BIG_FLOAT_DIGIT
) (acc
& 0xffff);
74 product
[1] = (_BIG_FLOAT_DIGIT
) (acc
>> 16);
75 product
[2] = (_BIG_FLOAT_DIGIT
) (carry
);
79 _multiply_base_ten_vector(short unsigned n
, _BIG_FLOAT_DIGIT
*px
,
80 short unsigned *py
, _BIG_FLOAT_DIGIT product
[3])
83 * Given xi and yi, base 10**4 vectors of length n, computes dot
86 * sum (i=0,n-1) of x[i]*y[n-1-i]
88 * Product may fill as many as three short-unsigned buckets. Product[0]
89 * is least significant, product[2] most.
92 #define ABASE 3000000000U /* Base of accumulator. */
100 for (i
= 0; i
< n
; i
++) {
101 acc
=_umac(px
[i
],py
[n
- 1 - i
],acc
);
102 if (acc
>= (unsigned long) ABASE
) {
111 which would overflow a short unsigned
113 product
[0] = (_BIG_FLOAT_DIGIT
) (acc
% 10000);
115 product
[1] = (_BIG_FLOAT_DIGIT
) (acc
% 10000);
117 product
[2] = (_BIG_FLOAT_DIGIT
) (acc
+ (ABASE
/ 100000000) * carry
);