| 1 |
'\" |
| 2 |
'\" Copyright (c) 1989-1993 The Regents of the University of California. |
| 3 |
'\" Copyright (c) 1994-1997 Sun Microsystems, Inc. |
| 4 |
'\" |
| 5 |
'\" See the file "license.terms" for information on usage and redistribution |
| 6 |
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 7 |
'\" |
| 8 |
.TH Tcl_PrintDouble 3 8.0 Tcl "Tcl Library Procedures" |
| 9 |
.so man.macros |
| 10 |
.BS |
| 11 |
.SH NAME |
| 12 |
Tcl_PrintDouble \- Convert floating value to string |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
\fB#include <tcl.h>\fR |
| 16 |
.sp |
| 17 |
\fBTcl_PrintDouble\fR(\fIinterp, value, dst\fR) |
| 18 |
.SH ARGUMENTS |
| 19 |
.AS Tcl_Interp *interp out |
| 20 |
.AP Tcl_Interp *interp in |
| 21 |
Before Tcl 8.0, the \fBtcl_precision\fR variable in this interpreter |
| 22 |
controlled the conversion. As of Tcl 8.0, this argument is ignored and |
| 23 |
the conversion is controlled by the \fBtcl_precision\fR variable |
| 24 |
that is now shared by all interpreters. |
| 25 |
.AP double value in |
| 26 |
Floating-point value to be converted. |
| 27 |
.AP char *dst out |
| 28 |
Where to store the string representing \fIvalue\fR. Must have at |
| 29 |
least \fBTCL_DOUBLE_SPACE\fR characters of storage. |
| 30 |
.BE |
| 31 |
.SH DESCRIPTION |
| 32 |
.PP |
| 33 |
\fBTcl_PrintDouble\fR generates a string that represents the value |
| 34 |
of \fIvalue\fR and stores it in memory at the location given by |
| 35 |
\fIdst\fR. It uses \fB%g\fR format to generate the string, with one |
| 36 |
special twist: the string is guaranteed to contain either a |
| 37 |
.QW . |
| 38 |
or an |
| 39 |
.QW e |
| 40 |
so that it does not look like an integer. Where \fB%g\fR would |
| 41 |
generate an integer with no decimal point, \fBTcl_PrintDouble\fR adds |
| 42 |
.QW .0 . |
| 43 |
.PP |
| 44 |
If the \fBtcl_precision\fR value is non-zero, the result will have |
| 45 |
precisely that many digits of significance. If the value is zero |
| 46 |
(the default), the result will have the fewest digits needed to |
| 47 |
represent the number in such a way that \fBTcl_NewDoubleObj\fR |
| 48 |
will generate the same number when presented with the given string. |
| 49 |
IEEE semantics of rounding to even apply to the conversion. |
| 50 |
.SH KEYWORDS |
| 51 |
conversion, double-precision, floating-point, string |