[Slightly OT]: More on ints and floats
Tim Daneliuk
tundra at tundraware.com
Tue Apr 8 18:50:08 CEST 2003
Lulu of the Lotus-Eaters wrote:
> Tim Daneliuk <tundra at tundraware.com> wrote previously:
> |As I understand it, integers and floats are distinct mathematical
> |entities. A colleague of mine claims, that insfar as we use them in
> |computing, ints are merely a proper subset of floats.
>
> Floats are peculiar creatures. They really are not much like Real or
> Rational numbers, even though it is often convenient to pretend they
> are. The trick about floating point numbers is that although they are
> extremely useful for representing real-life (fractional) quantities,
> operations on them do not obey the arithmetic rules we learned in middle
> school: associativity, transitivity, commutativity; moreover, many very
> ordinary-seeming numbers can be represented only approximately with
> floating point numbers. For example:
>
> >>> 1./3
> 0.33333333333333331
> >>> .3
> 0.29999999999999999
> >>> 7 == 7./25 * 25
> 0
> >>> 7 == 7./24 * 24
> 1
>
> Tim knows this, of course, but it is worth emphasizing. Moreover, a
> quote the Timbot found for this list a couple years ago is worth
> reiterating:
>
> Many serious mathematicians have attempted to analyze a
> sequence of floating point operations rigorously, but found
> the task so formidable that they have tried to be content
> with plausibility arguments instead.
> -- Donald Knuth (_The Art of Computer Programming_, Third Edition,
> Addison-Wesley, 1997; ISBN: 0201896842, vol. 2, p. 229):
>
> Yours, Lulu...
As a side note, this question was ultimately motivated by an entirely
different sort of "pure math" question: Does (integer) 1 = 1.0?
Engineers, physicists, and computer scientists all would
say "no" because of the precision problem with the latter number.
I am unclear, though, on whether a mathematician understands
1.0 to mean 1.0000000... (a single number) or the _neighborhood_
around 1 with one digit precision.
Thanks to all who took the time to respond...
--
----------------------------------------------------------------------------
Tim Daneliuk tundra at tundraware.com
PGP Key: http://www.tundraware.com/PGP/TundraWare.PGP.Keys.txt
More information about the Python-list
mailing list