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]
22 #pragma ident "%Z%%M% %I% %E% SMI"
25 * Copyright (c) 1988 by Sun Microsystems, Inc.
28 #include "base_conversion.h"
31 qeconvert(arg
, ndigits
, decpt
, sign
, buf
)
33 int ndigits
, *decpt
, *sign
;
38 fp_exception_field_type ef
;
40 static char *nanstring
= "NaN";
41 static char *infstring
= "Infinity";
45 dm
.rd
= fp_direction
; /* Rounding direction. */
46 dm
.df
= floating_form
; /* E format. */
47 dm
.ndigits
= ndigits
; /* Number of significant digits. */
48 quadruple_to_decimal(arg
, &dm
, &dr
, &ef
);
53 *decpt
= dr
.exponent
+ ndigits
;
54 for (i
= 0; i
< ndigits
; i
++)
60 for (i
= 0; i
< ndigits
; i
++)
78 for (i
= 0; i
< nc
; i
++)
83 return buf
; /* For compatibility with ecvt. */
87 qfconvert(arg
, ndigits
, decpt
, sign
, buf
)
89 int ndigits
, *decpt
, *sign
;
94 fp_exception_field_type ef
;
97 dm
.rd
= fp_direction
; /* Rounding direction. */
98 dm
.df
= fixed_form
; /* F format. */
99 dm
.ndigits
= ndigits
; /* Number of digits after point. */
100 quadruple_to_decimal(arg
, &dm
, &dr
, &ef
);
102 switch (dr
.fpclass
) {
106 *decpt
= dr
.ndigits
- ndigits
;
109 for (i
= 0; i
< dr
.ndigits
; i
++)
116 for (i
= 1; i
< ndigits
; i
++)
133 return buf
; /* For compatibility with fcvt. */
139 qgconvert(number
, ndigit
, trailing
, buf
)
141 int ndigit
, trailing
;
146 fp_exception_field_type fef
;
148 dm
.rd
= fp_direction
;
149 dm
.df
= floating_form
;
151 quadruple_to_decimal(number
, &dm
, &dr
, &fef
);
152 _gcvt(ndigit
, &dr
, trailing
, buf
);