Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!hp4nl!eutrc3!tuewsd!wsinkees From: wsinkees@lso.win.tue.nl (Kees Huizing) Newsgroups: comp.lang.pascal Subject: Re: Problem in Turbo Pascal 4.0 Keywords: Nonterminating Repeat loop, real, representation Message-ID: <803@tuewsd.lso.win.tue.nl> Date: 3 Jan 90 13:59:50 GMT References: <4658@ur-cc.UUCP> <4660@ur-cc.UUCP> Organization: Eindhoven University of Technology, The Netherlands Lines: 33 lowj_ltd@uhura.cc.rochester.edu (John Alan Low) writes: >In article <4658@ur-cc.UUCP> I wrote: >>I am having a problem with Turbo Pascal 4.0. The repeat loop in the following >>loop never terminates. >>Program Foo; >>var x : real; >>Begin >>x := 0.10; >> Repeat >> x := x + 0.01; >> Until x = 0.30; >>End. > Thanks to everybody who emailed me on this. I forgot that 0.01 is a > repeating decimal in binary. I never will again. > .... > Thanks again for all the help. (Boy, do I feel stupid) ^^^^^^^^^^^^^^^^^^^^^ It's not you that is stupid, it's (Turbo?) Pascal. Is it not the purpose of a high level pogramming language to hide the funny details of implementation and representation for the user? As it shows, the equality operator "=" does not on reals what it pretends to do. I accept that it cannot detect perfect equality of reals, but what it could do is detect equality upto some representation dependent accuracy. Why is it not done this way? Kees -- Kees Huizing - Eindhoven Univ of Techn - Dept Math & Comp Sc - The Netherlands DOMAIN: wsinkees@win.tue.nl BITNET: wsdckeesh@heitue5 FAX: +31-40-436685