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"
30 static char *nanstring
= "NaN";
31 static char *infstring
= "Infinity";
34 econvert(arg
, ndigits
, decpt
, sign
, buf
)
36 int ndigits
, *decpt
, *sign
;
41 fp_exception_field_type ef
;
46 dm
.rd
= fp_direction
; /* Rounding direction. */
47 dm
.df
= floating_form
; /* E format. */
48 dm
.ndigits
= ndigits
; /* Number of significant digits. */
49 double_to_decimal(&arg
, &dm
, &dr
, &ef
);
54 *decpt
= dr
.exponent
+ ndigits
;
55 for (i
= 0; i
< ndigits
; i
++)
61 for (i
= 0; i
< ndigits
; i
++)
79 for (i
= 0; i
< nc
; i
++)
84 return buf
; /* For compatibility with ecvt. */
88 fconvert(arg
, ndigits
, decpt
, sign
, buf
)
90 int ndigits
, *decpt
, *sign
;
95 fp_exception_field_type ef
;
100 dm
.rd
= fp_direction
; /* Rounding direction. */
101 dm
.df
= fixed_form
; /* F format. */
102 dm
.ndigits
= ndigits
; /* Number of digits after point. */
103 double_to_decimal(&arg
, &dm
, &dr
, &ef
);
105 switch (dr
.fpclass
) {
109 *decpt
= dr
.ndigits
- ndigits
;
112 for (i
= 0; i
< dr
.ndigits
; i
++)
119 for (i
= 1; i
< ndigits
; i
++)
137 for (i
= 0; i
< nc
; i
++)
142 return buf
; /* For compatibility with fcvt. */