Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!maytag!watstat!dmurdoch From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch) Newsgroups: comp.lang.pascal Subject: Re: Problem in Turbo Pascal 4.0 Keywords: Nonterminating Repeat loop, real, representation, binary coded decimal Message-ID: <1080@maytag.waterloo.edu> Date: 4 Jan 90 00:42:36 GMT References: <4658@ur-cc.UUCP> <4660@ur-cc.UUCP> <803@tuewsd.lso.win.tue.nl> <4679@ur-cc.UUCP> Sender: daemon@maytag.waterloo.edu Reply-To: dmurdoch@watstat.waterloo.edu (Duncan Murdoch) Organization: U. of Waterloo, Ontario Lines: 21 In article <4679@ur-cc.UUCP> lowj_ltd@uhura.cc.rochester.edu (John Alan Low, aka "Travis" Low) writes: > After I read this, I compiled the program with the Turbo Pascal 3.0 > turbobcd.com compiler. Guess what? The loop terminates nicely. Also, > expressions such as 1/3 + 2/3 come out equal to 1.0. So the binary- > coded representation of decimals works nicely, and the "=" works the > way it's supposed to. It's not surprising that the original sum of 0.01's came out exact, because they can be represented exactly in BCD. I think you were just lucky with the other one - you probably added 0.3...33 + 0.6...67 and got 1. You might try it again adding 3 copies of 1/3, and should get 0.999... > > Is there some reason this representation is not common practice? > Can anybody shed some light on this? I think that later versions of > Turbo Pascal do not implement this representation, so there must be > some good reason, right? You're right about recent (4.0+) versions of TP. You can get them in the Turbo Professional library from Turbopower, if you want. Duncan Murdoch