Path: utzoo!mnetor!uunet!husc6!mailrus!ames!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!sdcrdcf!sdcsmb!sea!eggert From: eggert@sea.sm.unisys.com (Paul Eggert) Newsgroups: comp.lang.prolog Subject: Re: Arithmetic problems with Quintus Prolog Message-ID: Date: 12 Apr 88 16:10:48 GMT References: <11111@shemp.CS.UCLA.EDU> <869@cresswell.quintus.UUCP> Reply-To: eggert@sea.sm.unisys.com (Paul Eggert) Organization: Unisys Santa Monica Lines: 20 In article <869@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: 0.0 -vs- -0.0 -- mandated by IEEE ... 1 \== 1.0 -- implicitly mandated by IEEE The IEEE standard does not implicitly mandate that 1 \== 1.0. Consider the following rule, used by Silogic Prolog: If a number can be exactly represented in both floating point and integer formats, then use integer format. With this rule 1 == 1.0, and 0 == 0.0, but 0 \== -0.0 because 0 and -0.0 are not the same number. This rule matches most people's intuition better than Quintus's conversion rules. It's not as fast as Quintus's arithmetic, but if you prize correct answers over fast ones, you will insist on overflow checking anyway, and you may find that a cheap test for the question "Is the number X exactly representable in integer format?" folds naturally into overflow checking.