Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Floating Point Message-ID: <2524@munnari.oz.au> Date: 25 Oct 89 06:11:15 GMT References: <2491@munnari.oz.au> <36169@srcsip.UUCP> Sender: news@cs.mu.oz.au Lines: 31 In article <36169@srcsip.UUCP>, shankar@SRC.Honeywell.COM (Subash Shankar) writes: > With all the talk about floating point in Prolog, I was wondering if > there any Prolog's which unify "close" floating point numbers. At least two: IBM's VM/Prolog and SB Prolog. > Would this make sense? In a word, ***NO***. It would make a *great* deal of sense to have an *additional* set of "fuzzy comparison" predicates (see Knuth Vol 2 for a good set). But it makes no sense at all to pervert unification. If you unify X with Y whenever |X-Y| < epsilon.max(|X|,|Y|), then the effect of that is to *REDUCE* your precision to epsilon. For example, Stony-Brook Prolog has its own internal format for floating-point numbers which buys it about 6 decimal digits of precision. But it uses fuzzy unification with epsilon = 1.0e-5. That is, it throws away one whole decimal digit. Writing numeric code in such a dialect is a nightmare. Precise comparison is important in many numeric applications. From the logical point of view, the nasty thing about fuzzy comparison is that it is not transitive. Let epsilon be 1.0e-5, and compute Y is 1.0, X is Y-6.0e-6, Z is Y+6.0e-6 Now, using fuzzy unification, we would get X = Y (relative error is 0.6e-5 < 1.0e-5) Y = Z (relative error is 0.6e-5 < 1.0e-5) BUT NOT X = Z (relative error is 1.2e-5 > 1.0e-5) Making unification non-transitive is not an improvement to the language.