Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!swrinde!ucsd!ames!skipper!elxsi!maine From: maine@elxsi.dfrf.nasa.gov (Richard Maine) Newsgroups: comp.lang.pascal Subject: Re: Problem in Turbo Pascal 4.0 Message-ID: Date: 9 Jan 90 17:20:14 GMT References: <4658@ur-cc.UUCP> <1989Dec30.135702.12086@cs.dal.ca> <1990Jan9.051558.16015@waikato.ac.nz> Sender: news@skipper.dfrf.nasa.gov Followup-To: <1989Dec30.135702.12086@cs.dal.ca> Organization: NASA Dryden, Edwards, Cal. Lines: 35 In-reply-to: ldo@waikato.ac.nz's message of 9 Jan 90 05:15:58 GMT On 9 Jan 90 05:15:58 GMT, ldo@waikato.ac.nz (Lawrence D'Oliveiro) said: Lawrence> Anybody who says "You should never check for equality with reals" Lawrence> obviously hasn't used a system that supports IEEE 754 arithmetic! This whole subject really has little to do with Pascal, but here goes anyway... I'm afraid, I don't understand the above comment. I'd have thought just the opposite. Anybody that is careful about writing robust and portable floatting point code should be extremely leary of equality tests for reals. Some are "safer" that others, but any such test should make a careful programmer hesitate. Likewise, those people concerned about writing well-behaved numerical programs generally applaud IEEE 754 as one of the best floatting point representations for serious numerical work. I would suppose that those people liking IEEE 754 would be among those most careful about such things as floatting point equality tests because IEEE 754 is careful about far more subtle issues. Its true that you _can_ do equality comparisons on IEEE 754 numbers, just like you can on most other formats, but that doesn't make it a good idea. It's also true that increasing conformance to IEEE 754 improves the odds that such an equality test might actually give the same results on 2 different systems, but it does little to guarrantee that both systems won't give the same "wrong" result. Anyway, I program on several IEEE 754 systems and I certainly say "you should never (well almost never) check for equality with reals." Perhaps I missed a "smiley face" in the comment quoted above, but it just doesn't make any sense to me. -- Richard Maine maine@elxsi.dfrf.nasa.gov [130.134.64.6]