Re: Embarrassing Arithmetic behaviour
"Richard A. O'Keefe" <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 20/02/2014, at 9:32 PM, Lukas Degener wrote:
> Am 20.02.2014 00:06, schrieb Richard A. O'Keefe:
>
>> Nobody graduates from this department without having done several
>> hours of exercises designed to convince them that floating point
>> arithmetic is not mathematical real number arithmetic.
>
> Ah yes, there is just so *much* stuff that really, really everyone
> should know, but surprisingly few of us do.
1st year: programming in Python (integers just work, floats are
slightly odd) and Java (integers definitely don't work
but not to worry...)
2nd year: computer architecture. What computer arithmetic
actually does. What is 2s complement. Why does
int i, j; ... j = i < 0 ? -i : i; sometimes leave
j negative? What does short k = 32767; k++; do and why?
What do floating-point numbers look like in a computer?
When you ask for 0.1 what do you actually get? What is
overflow?
3rd year: effective programming. Why is the left to right sum of
a bunch of floats different from the right to left sum?
Does using double precision always give better answers
than using single precision? These two simple expressions
are mathematically equal, what happens on the computer?
This takes about four hours.
I mean, surely if you are going to use a programming language
that has these things called floating-point numbers, you WANT
to find out what they ARE and what they DO before you use them?
>
> Yet here I am, and floating point arithmetic still gives me the creeps.
> I guess this means that I did not graduate from "this" (your?) department.
It could mean that you _did_ graduate from this department
and we _succeeded_ in scaring you enough to be wary, but not
enough to persuade you to take a numerical analysis paper from
the Maths department.