On Sun, Dec 29, 2019 at 2:44 PM David Mertz <me...@gnosis.cx> wrote: > > On Sat, Dec 28, 2019 at 10:31 PM Richard Damon <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) > > 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.
It's not about numbers, it's about the nature of addition in the real numbers. Since floats are a subset of real numbers, it is entirely possible for the result of any operation to be outside of the subset representable as floats. > 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. > They really truly ARE numbers. They are, in fact, these numbers: a = 3602879701896397 / 36028797018963968 b = 3602879701896397 / 18014398509481984 c = 5404319552844595 / 18014398509481984 When you perform addition on these, the result must repeatedly be rounded to the available resolution. This is not about numbers, it is about limited subsets of numbers. ChrisA _______________________________________________ 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/G6FIWN2CJM6SJRWTDOQL3V4RV7XZVRDD/ Code of Conduct: http://python.org/psf/codeofconduct/