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

  1. Path: sparky!uunet!stanford.edu!agate!sprite.Berkeley.EDU!ouster
  2. From: ouster@sprite.Berkeley.EDU (John Ousterhout)
  3. Newsgroups: comp.lang.tcl
  4. Subject: Re: bug in expr?
  5. Date: 22 Jul 1992 20:26:35 GMT
  6. Organization: U.C. Berkeley Sprite Project
  7. Lines: 18
  8. Distribution: world
  9. Message-ID: <14kg9rINNdj7@agate.berkeley.edu>
  10. References: <1992Jul21.215415.23716@crd.ge.com>
  11. NNTP-Posting-Host: tyranny.berkeley.edu
  12. Keywords: expr, integer, floating, arithmetic
  13.  
  14. In article <1992Jul21.215415.23716@crd.ge.com>, kennykb@dssv01.crd.ge.com (Kevin B. Kenny) writes:
  15. |> 
  16. |> Can someone explain the following?  More to the point, can someone fix it?
  17. |> 
  18. |> wish: set x [expr 400000.0+500000.0]
  19. |> 900000
  20. |> wish: set y [expr $x*$x]
  21. |> -1748818944
  22. |> 
  23. |> The square of 900000.0 oughtn't to be a large negative number.
  24. |> 
  25. |> 
  26. |> 73 de ke9tv/2, Kevin          There isn't any .signature virus, is there?
  27.  
  28. Adrian Ho's right about the problem, namely that implicit floating-to-
  29. integer conversion is occurring in expr.  His solutions will probably
  30. work OK, although they're a little ugly.  I'll see if I can find a solution
  31. that is both clean and correct.
  32.