|
From: <and...@us...> - 2009-08-25 14:36:56
|
Revision: 10328
http://plplot.svn.sourceforge.net/plplot/?rev=10328&view=rev
Author: andrewross
Date: 2009-08-25 14:36:42 +0000 (Tue, 25 Aug 2009)
Log Message:
-----------
Use Tcl_PrintDouble to convert doubles to strings. This takes note of the tcl_precision variable and ensures the returned string is always a double (i.e. contains a decimal place or an exponent).
Modified Paths:
--------------
trunk/bindings/tcl/pltclgen.tcl
trunk/bindings/tcl/tclMatrix.c
Modified: trunk/bindings/tcl/pltclgen.tcl
===================================================================
--- trunk/bindings/tcl/pltclgen.tcl 2009-08-25 13:07:06 UTC (rev 10327)
+++ trunk/bindings/tcl/pltclgen.tcl 2009-08-25 14:36:42 UTC (rev 10328)
@@ -281,7 +281,7 @@
# precision standard (global var tcl_precision).
"PLFLT&" {
- puts $GENFILE " sprintf( buf, \"%.20g\", $argname($i) );"
+ puts $GENFILE " Tcl_PrintDouble( interp, $argname($i), buf );"
puts $GENFILE " if (argc > 1)"
puts $GENFILE " Tcl_SetVar( interp, argv\[1+$i\], buf, 0 );"
puts $GENFILE " else";
Modified: trunk/bindings/tcl/tclMatrix.c
===================================================================
--- trunk/bindings/tcl/tclMatrix.c 2009-08-25 13:07:06 UTC (rev 10327)
+++ trunk/bindings/tcl/tclMatrix.c 2009-08-25 14:36:42 UTC (rev 10328)
@@ -642,7 +642,8 @@
Mat_float max = matPtr->fdata[0];
for (i = 1; i < len; i++)
max = MAX(max, matPtr->fdata[i]);
- sprintf(tmp, "%.17g", max);
+ /*sprintf(tmp, "%.17g", max);*/
+ Tcl_PrintDouble(interp, max, tmp);
Tcl_AppendResult(interp, tmp, (char *) NULL);
break;
}
@@ -678,7 +679,8 @@
Mat_float min = matPtr->fdata[0];
for (i = 1; i < len; i++)
min = MIN(min, matPtr->fdata[i]);
- sprintf(tmp, "%.17g", min);
+ /*sprintf(tmp, "%.17g", min);*/
+ Tcl_PrintDouble(interp, min, tmp);
Tcl_AppendResult(interp, tmp, (char *) NULL);
break;
}
@@ -891,7 +893,8 @@
tclMatrix *matPtr = (tclMatrix *) clientData;
double value = matPtr->fdata[index];
- sprintf(string, "%.17g", value);
+ /*sprintf(string, "%.17g", value);*/
+ Tcl_PrintDouble(interp, value, string);
}
static void
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|