home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.eiffel
- Path: sparky!uunet!ukma!darwin.sura.net!uvaarpa!murdoch!cds001.cebaf.gov!quarrie
- From: quarrie@cds001.cebaf.gov (David Quarrie)
- Subject: Re: if then else strange things..
- Message-ID: <1992Nov17.193605.405@murdoch.acc.Virginia.EDU>
- Sender: usenet@murdoch.acc.Virginia.EDU
- Reply-To: quarrie@cds001.cebaf.gov (David Quarrie)
- Organization: CEBAF (Continuous Electron Beam Accelerator Facility)
- References: <1992Nov17.164713.6958@purelogic.cs.uwlax.edu>
- Date: Tue, 17 Nov 1992 19:36:05 GMT
- Lines: 80
-
- --
- In article <1992Nov17.164713.6958@purelogic.cs.uwlax.edu>,
- butte_ms@pascal.uwlax.edu (Mike S. Butterbrodt S92) writes:
- |>Newsgroups: comp.lang.eiffel
- |>Path:
- |
- murdoch!uvaarpa!darwin.sura.net!zaphod.mps.ohio-state.edu!saimiri.primat
- te.wisc.edu!zazen!purelogic!usenet
- |>From: butte_ms@pascal.uwlax.edu (Mike S. Butterbrodt S92)
- |>Subject: if then else strange things..
- |>Message-ID: <1992Nov17.164713.6958@purelogic.cs.uwlax.edu>
- |>Sender: usenet@purelogic.cs.uwlax.edu (News Poster)
- |>Nntp-Posting-Host: pascal.wing.uwlax.edu
- |>Organization: University of Wisconsin - La Crosse Computer Science
- |>Department
- |>Date: Tue, 17 Nov 1992 16:47:13 GMT
- |>Lines: 36
- |>
- |> Gotta neat problem......
- |>
- |> For a class we are creating a logic gate simulator. In one of the
- |>gates, we
- |>toggle the color with
- |> a mouse down event. (From Black to Light_gray).
- |>
- |> We are using Postscript commands on a NeXT enviroment, but that
- |>should be
- |>irrelevant for this problem.
- |>
- |>
- |> My first attempt was ::::
- |> -- When the gates are initially created status_color :=
- |>Black;
- |>
- |> the mouse_down event method contains this (among other non-related
- |>things)
- |>
- |> if status_color = Light_gray then
- |> status_color := Black;
- |> else
- |> status_color := Light_gray;
- |> end;
- |> display;
- |> This changed the color to Light_gray, but would not change it back on
- |>|>successive mouse downs.
- |> However, this worked.....
- |>
- |> if status_color = Black then
- |> status_color := Light_gray;
- |> else
- |> status_color := Black;
- |> end;
- |> display;
- |>
- |>It works now, so I am happy. But this is very curious. Any
- |>answers???
- |>
- |> Mike Butterbrodt, UW_La
- |>Crosse Comp.
- |>Sci.
- |>
-
- I think the problem is floating point comparisons. Black is defined as 0.0 (I
- think, I'm not in front of my NeXT right now so will have to check
- later) whereas
- Light_gray is defined as 0.67 (or thereabouts). Checking against 0.0 is
- exact
- but checking against 0.67 is not exact (because the floating point
- representations are not exact). I hate to think how many times that
- caught me
- during my FORTRAN coding days!
-
- No doubt someone will correct me if I'm talking through a hole in my head.
-
- -------------------------------------------------------------------------------
- David Quarrie CEBAF MS 12H
- 12000 Jefferson Ave
- Internet: quarrie@cebaf.gov Newport News VA 23606
- DECnet : cebaf::quarrie Tel: (804) 249-7562
- BITNET : quarrie@cebaf Fax: (804) 249-7363
-