home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!agate!agate!adrianho
- From: adrianho@barkley.berkeley.edu (Adrian J Ho)
- Newsgroups: comp.lang.tcl
- Subject: Re: bug in expr?
- Date: 22 Jul 92 04:15:20
- Organization: University of California, Berkeley
- Lines: 50
- Message-ID: <ADRIANHO.92Jul22041520@barkley.berkeley.edu>
- References: <1992Jul21.215415.23716@crd.ge.com>
- <ADRIANHO.92Jul22040954@barkley.berkeley.edu>
- NNTP-Posting-Host: barkley.berkeley.edu
- In-reply-to: adrianho@barkley.berkeley.edu's message of 22 Jul 92 04:09:54
-
- In article <ADRIANHO.92Jul22040954@barkley.berkeley.edu> adrianho@barkley.berkeley.edu (Adrian J Ho) writes:
- > (2) Change %g above to %e or %f. Disadvantage: Some numbers will
- > look ugly (eg. 900000.0 is returned as 900000.000000). Apply
- > the following patch (change %e to %f if that's your liking):
-
- Oops, the patch was incomplete -- there were two instances of
- double-to-string conversion. Here's the "definitive" one:
-
- *** tclExpr.c~ Mon Mar 23 09:54:06 1992
- --- tclExpr.c Wed Jul 22 04:12:24 1992
- ***************
- *** 1124,1130 ****
- if (valuePtr->type == TYPE_INT) {
- sprintf(valuePtr->pv.buffer, "%ld", valuePtr->intValue);
- } else if (valuePtr->type == TYPE_DOUBLE) {
- ! sprintf(valuePtr->pv.buffer, "%g", valuePtr->doubleValue);
- }
- valuePtr->type = TYPE_STRING;
- }
- --- 1124,1130 ----
- if (valuePtr->type == TYPE_INT) {
- sprintf(valuePtr->pv.buffer, "%ld", valuePtr->intValue);
- } else if (valuePtr->type == TYPE_DOUBLE) {
- ! sprintf(valuePtr->pv.buffer, "%e", valuePtr->doubleValue);
- }
- valuePtr->type = TYPE_STRING;
- }
- ***************
- *** 1318,1324 ****
- if (value.type == TYPE_INT) {
- sprintf(interp->result, "%ld", value.intValue);
- } else if (value.type == TYPE_DOUBLE) {
- ! sprintf(interp->result, "%g", value.doubleValue);
- } else {
- if (value.pv.buffer != value.staticSpace) {
- interp->result = value.pv.buffer;
- --- 1318,1324 ----
- if (value.type == TYPE_INT) {
- sprintf(interp->result, "%ld", value.intValue);
- } else if (value.type == TYPE_DOUBLE) {
- ! sprintf(interp->result, "%e", value.doubleValue);
- } else {
- if (value.pv.buffer != value.staticSpace) {
- interp->result = value.pv.buffer;
- --
- -----------------------------------------------------------------------------
- Adrian Ho, He With The Embarrassingly *Dead* Passion ** Phone: (510) 642-5563
- System Manager, CFD Lab, ME Dept, UC Berkeley * adrianho@barkley.berkeley.edu
- Maintainer, Tcl/Tk Contrib Archive ---- barkley.berkeley.edu [128.32.142.237]
- Send all Tcl/Tk Archive-related stuff to tcl-archive@barkley.berkeley.edu
-