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