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

Why is there no REAL number data type?

    Date: Mon, 29 Jan 90 17:23:49 -0500
    From: barr@bbn.com (Hunter Barr)

    Now, can anyone tell me why Common Lisp floating-point numbers are not considered a
    subset of rationals?  I find that 

Because they don't behave like rationals, because of the fixed sizes of
the components.  With floating point it's possible to have (= (+ A B) A)
be true when B isn't 0.0; for instance, try (= (+ 1e10 1e-10) 1e10).
Floating point also has roundoff errors; take a look at (rational 1e-10)
and (rationalize 1e-10), and notice that neither of them is
1/10000000000.  Finally, floating point number underflow and overflow
much sooner than rationals; on the Lispm, single floats max out at
3.4e38, and double floats at 1.8e308, while rationals are only limited
by available memory.