| [25] | 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 | '\" RCS: @(#) $Id: PrintDbl.3,v 1.11 2007/12/13 15:22:31 dgp Exp $ |
|---|
| 9 | '\" |
|---|
| 10 | .so man.macros |
|---|
| 11 | .TH Tcl_PrintDouble 3 8.0 Tcl "Tcl Library Procedures" |
|---|
| 12 | .BS |
|---|
| 13 | .SH NAME |
|---|
| 14 | Tcl_PrintDouble \- Convert floating value to string |
|---|
| 15 | .SH SYNOPSIS |
|---|
| 16 | .nf |
|---|
| 17 | \fB#include <tcl.h>\fR |
|---|
| 18 | .sp |
|---|
| 19 | \fBTcl_PrintDouble\fR(\fIinterp, value, dst\fR) |
|---|
| 20 | .SH ARGUMENTS |
|---|
| 21 | .AS Tcl_Interp *interp out |
|---|
| 22 | .AP Tcl_Interp *interp in |
|---|
| 23 | Before Tcl 8.0, the \fBtcl_precision\fR variable in this interpreter |
|---|
| 24 | controlled the conversion. As of Tcl 8.0, this argument is ignored and |
|---|
| 25 | the conversion is controlled by the \fBtcl_precision\fR variable |
|---|
| 26 | that is now shared by all interpreters. |
|---|
| 27 | .AP double value in |
|---|
| 28 | Floating-point value to be converted. |
|---|
| 29 | .AP char *dst out |
|---|
| 30 | Where to store the string representing \fIvalue\fR. Must have at |
|---|
| 31 | least \fBTCL_DOUBLE_SPACE\fR characters of storage. |
|---|
| 32 | .BE |
|---|
| 33 | |
|---|
| 34 | .SH DESCRIPTION |
|---|
| 35 | .PP |
|---|
| 36 | \fBTcl_PrintDouble\fR generates a string that represents the value |
|---|
| 37 | of \fIvalue\fR and stores it in memory at the location given by |
|---|
| 38 | \fIdst\fR. It uses \fB%g\fR format to generate the string, with one |
|---|
| 39 | special twist: the string is guaranteed to contain either a |
|---|
| 40 | .QW . |
|---|
| 41 | or an |
|---|
| 42 | .QW e |
|---|
| 43 | so that it does not look like an integer. Where \fB%g\fR would |
|---|
| 44 | generate an integer with no decimal point, \fBTcl_PrintDouble\fR adds |
|---|
| 45 | .QW .0 . |
|---|
| 46 | .VS 8.5 |
|---|
| 47 | .PP |
|---|
| 48 | If the \fBtcl_precision\fR value is non-zero, the result will have |
|---|
| 49 | precisely that many digits of significance. If the value is zero |
|---|
| 50 | (the default), the result will have the fewest digits needed to |
|---|
| 51 | represent the number in such a way that \fBTcl_NewDoubleObj\fR |
|---|
| 52 | will generate the same number when presented with the given string. |
|---|
| 53 | IEEE semantics of rounding to even apply to the conversion. |
|---|
| 54 | .VE |
|---|
| 55 | |
|---|
| 56 | .SH KEYWORDS |
|---|
| 57 | conversion, double-precision, floating-point, string |
|---|