[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: navajo!Common-Lisp%su-ai@navajo.stanford.edu*Subject*: Numerical Comparison: "required coercions"*From*: edsel!bhopal!jonl@navajo.stanford.edu (Jon L White)*Date*: Wed, 25 Mar 87 14:52:35 PST

Section 12.3 of CLtL, when speaking of the numerical comparison functions -- =, /=, <, etc. -- says that each one works on all types of numbers (unless otherwise indicated), and that any "required coercions" are performed when the arguments are of different type. Which kind of coercion is appropriate for the following: (= 314159265358979383256 ;about 20 digits of pi, as integer 3.1415925E20 ; pi * 1.0E20, off by one lsb maybe 314159265358979383250 ;a different "20 digits" of pi ) ?? Some implementations I've looked at appear to do the coercion by the usual rule of float-contagion. I believe this to be sub-optimal in that it prevents "=" from being a transitive operation (because floating the two integers above will typically "lose" information). Wouldn't it make more sense to consider the phrase "required coercions" to mean that when a rational is compared to a float, it is the float that is "coerced" rather than the rational? In short, I don't think the original intent was that "=" be a "fuzzy" operation. Rather it should be mathematically consistent, even if the interpretation of "precision" for floating-point numbers is open to question. -- JonL --

**Follow-Ups**:**Numerical Comparison: "required coercions"***From:*David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>

- Prev by Date:
**Extension to MAP** - Next by Date:
**Replies to Extension to MAP** - Previous by thread:
**(THE (VALUES ...) ...) with &KEY** - Next by thread:
**Numerical Comparison: "required coercions"** - Index(es):