On 12/28/19 10:41 PM, David Mertz wrote:
On Sat, Dec 28, 2019 at 10:31 PM Richard Damon
<rich...@damon-family.org <mailto:rich...@damon-family.org>> wrote:
Every value of the type float, except NaN and perhaps +inf and -inf
(depending on which version of the Real Number Line you use) IS
actually
a representation of a Real Number (so I don't understand in what
way you
can say they aren't "numbers"). And yes, they happen to also be
Rationals.
This is not subtle, and it is not something you do not understand. C'mon.
Tell me three Real Numbers (or Rational Numbers) such that:
(a + b) + c != a + (b + c)
Yes, the floating point approximation says that + in computer
programming is not exactly the ideal + in the domains of the Reals,
understanding the difference is important. It is well known that
floating point arithmetic has properties that make it not a finite
field, and that ISN'T a real problem, as it is a well defined
approximation to a Real Field, and thus when you take into account the
limits of the approximations, you CAN say that it approximates the
numeric field, which is good enough for computer science. (and there is
a lot of math available to allow you to evaluate how good your
approximation is.)
This also brings us to the first rule of floating point math, looking
for exact equality, particularly after a calculation, is almost never
the correct action.
You will not succeed in that endeavor because of the nature of "numbers."
... and yes, because of the usual meaning given to the symbol '+', etc.
OK... now I'll tell you three floating point "numbers" that follow
that pattern:
a = float("0.1")
b = float("0.2")
c = float("0.3")
We can conveniently write the constructors for these in Python as
`0.1` and so on. These objects that occupy computer memory are not
"numbers" in the sense of obeying the axioms of arithmetic. But they
kinda-sorta resemble numbers, and computers can do things with them
quickly, so we pretend.
yes, you can create these numbers in Python (and they are NOT the
numbers 0.1, 0.2, and 0.3, (by my tests, the first two are slightly
larger, and the last smaller) and that distinction is important and
often missed by people who don't understand what floating point number
is computers actually are. And YES, they ARE numbers in the sense of the
Real Number Field, the issue is that the + operator isn't the exact
mathematical operation, but an approximation to it, with fairly precise
definition of how it differs from the precise mathematical operation.
Let me ask you a question, do you have any real experience in
computational number theory? You are taking a stance like you think you
do, but arguments don't show it, being a bit on the novice level.
--
Richard Damon
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/R4CMWW2IKHYVX2NOD36RH2JBZKWKES4G/
Code of Conduct: http://python.org/psf/codeofconduct/