[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (- 2.8 1.6) ; 1.1999999999999997
From: |
Stefan Monnier |
Subject: |
Re: (- 2.8 1.6) ; 1.1999999999999997 |
Date: |
Mon, 10 Feb 2020 20:31:56 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (- 2.8 1.6) ; 1.1999999999999997
Emacs Lisp, like most common programming language doesn't support
rational numbers (and even less real numbers, which can't be faithfully
represented in a computer) but only floating point numbers. And like
most programming languages it uses the standard IEEE representation
supported natively by most CPUs. This representation can't represent
2.8 nor 1.6 (and nor 1.2) exactly.
It so happens that "the representable number closest to 2.8" minus "the
representable number closest to 1.6" is not equal to "the representable
number closest to 1.2".
> With the TI-84 Plus,
>
> 2.8-1.6=1.2
IIUC those calculators used a decimal floating point representation,
which suffers from the same kinds of problems of course, but works
better in this specific case.
Stefan