Re: [AC21.5] Texinfo manual kilo-patch
Jeff Mincy <[email protected]> Fri, 30 Apr 2004 20:14:24 -0400
| Newsgroups | gmane.emacs.xemacs.design |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 01 May 2004, [email protected] wrote: > Jeff Mincy <[email protected]> writes: > >>> In other words, would anything break if (* 1.0 1/3) converted 1.0 >>> to 1/1 and returned 1/3? >> >> Yes, this would break compatibility with common lisp. > > I meant, anything other than compatibility with Common Lisp (which we > don't have anyway). Things like existing code, common sense, widely > adopted usage, etc. > > For example, one might argue that it's strange for (+ .1 1) to return > 1 10000000000000001/100000000000000000 instead of 1.1. (It can't > return 1 1/10 because 0.1 is not really 1/10.) Well[1]. Actually, it could return 11/10. It depends completely on what you are assuming[2]. Are floats precise or approximations? * (rational (float 11/10)) 9227469/8388608 * (rationalize (float 11/10)) 11/10 from CLtL: Rational assumes that the floating-point number is completely accurate and returns a number mathematically equal to the precise value. Rationalize assumes that the floating point number is accurate only to the precision of the floating point representation and may return any rational number for which the floating-point number is the best available approximation of it's format. The manual says that rationalize may return any number, but the point of the function is that it return the best rational with the smallest denominator. Stephen made a comment "conversion to a rational claims that you've acquired an infinite amount of precision from somewhere." this statement is overstated - the claim is only that the floating point number is precise in its representation, not that it has infinite precision. The floating number is precise, you don't need any more bits (they are all zero bits). Footnotes: [1] converting to rational would be strange. [2] converting to exact rationals would be a good test of the bignum implementation. * (* (rational (float 1/3)) (rational (float 1/7)) (rational (float 1/11))) 327090353277982423173/75557863725914323419136 * (* (rationalize (float 1/3)) (rationalize (float 1/7)) (rationalize (float 1/11))) 1/231 -jeff