home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / tcl / 1021 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  2.7 KB

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!agate!agate!adrianho
  2. From: adrianho@barkley.berkeley.edu (Adrian J Ho)
  3. Newsgroups: comp.lang.tcl
  4. Subject: Re: bug in expr?
  5. Date: 22 Jul 92 04:15:20
  6. Organization: University of California, Berkeley
  7. Lines: 50
  8. Message-ID: <ADRIANHO.92Jul22041520@barkley.berkeley.edu>
  9. References: <1992Jul21.215415.23716@crd.ge.com>
  10.     <ADRIANHO.92Jul22040954@barkley.berkeley.edu>
  11. NNTP-Posting-Host: barkley.berkeley.edu
  12. In-reply-to: adrianho@barkley.berkeley.edu's message of 22 Jul 92 04:09:54
  13.  
  14. In article <ADRIANHO.92Jul22040954@barkley.berkeley.edu> adrianho@barkley.berkeley.edu (Adrian J Ho) writes:
  15. >      (2) Change %g above to %e or %f.  Disadvantage: Some numbers will
  16. >          look ugly (eg. 900000.0 is returned as 900000.000000).  Apply
  17. >          the following patch (change %e to %f if that's your liking):
  18.  
  19. Oops, the patch was incomplete -- there were two instances of
  20. double-to-string conversion.  Here's the "definitive" one:
  21.  
  22. *** tclExpr.c~  Mon Mar 23 09:54:06 1992
  23. --- tclExpr.c   Wed Jul 22 04:12:24 1992
  24. ***************
  25. *** 1124,1130 ****
  26.       if (valuePtr->type == TYPE_INT) {
  27.         sprintf(valuePtr->pv.buffer, "%ld", valuePtr->intValue);
  28.       } else if (valuePtr->type == TYPE_DOUBLE) {
  29. !       sprintf(valuePtr->pv.buffer, "%g", valuePtr->doubleValue);
  30.       }
  31.       valuePtr->type = TYPE_STRING;
  32.   }
  33. --- 1124,1130 ----
  34.       if (valuePtr->type == TYPE_INT) {
  35.         sprintf(valuePtr->pv.buffer, "%ld", valuePtr->intValue);
  36.       } else if (valuePtr->type == TYPE_DOUBLE) {
  37. !       sprintf(valuePtr->pv.buffer, "%e", valuePtr->doubleValue);
  38.       }
  39.       valuePtr->type = TYPE_STRING;
  40.   }
  41. ***************
  42. *** 1318,1324 ****
  43.         if (value.type == TYPE_INT) {
  44.             sprintf(interp->result, "%ld", value.intValue);
  45.         } else if (value.type == TYPE_DOUBLE) {
  46. !           sprintf(interp->result, "%g", value.doubleValue);
  47.         } else {
  48.             if (value.pv.buffer != value.staticSpace) {
  49.                 interp->result = value.pv.buffer;
  50. --- 1318,1324 ----
  51.         if (value.type == TYPE_INT) {
  52.             sprintf(interp->result, "%ld", value.intValue);
  53.         } else if (value.type == TYPE_DOUBLE) {
  54. !           sprintf(interp->result, "%e", value.doubleValue);
  55.         } else {
  56.             if (value.pv.buffer != value.staticSpace) {
  57.                 interp->result = value.pv.buffer;
  58. --
  59. -----------------------------------------------------------------------------
  60. Adrian Ho, He With The Embarrassingly *Dead* Passion ** Phone: (510) 642-5563
  61. System Manager, CFD Lab, ME Dept, UC Berkeley * adrianho@barkley.berkeley.edu
  62. Maintainer, Tcl/Tk Contrib Archive ---- barkley.berkeley.edu [128.32.142.237]
  63.   Send all Tcl/Tk Archive-related stuff to tcl-archive@barkley.berkeley.edu
  64.