Re: Precision issue with Float and Double (C++)
- From: "David Webber" <dave@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Aug 2008 19:36:12 +0100
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message news:8ildb4lur15s40mvnaid8eo0k597rbb8t3@xxxxxxxxxx
Rule 1: There is no such thing as "decimal precision" in floating point
Rule 2: If you are having problems with "decimal precision", consult rule 1
Rule 3: If are convinced double should work like decimal arithmetic, consult Rule 1.
Rule 4: If you still believe double should work like decimal arithmetic, choose another
profession.
:-)
Rule 5: interpret Joe's rules carefully :-)
..
If the error is "significant enough to affect my calculation" then your calculation is not
designed correctly. One of the first things we teach students in computing is that you
must *not ever* create a computation which is sensitive to the binary representation
issues of floating point, and in fact, numerical analysts have known about this problem
since the 1940s (John von Neumann, the inventor of the modern stored-program computer,
identified all of these issues AND how to deal with them, before I was born, which was
1947, and they were known to a lesser degree in the 1920s with mechanical calculators
(decimal arithmetic has EXACTLY the same problems), ...
Indeed. It is the subject of "Numecial Maths" which, as you observe, rather predates that of "Windows programming"
My first programming exercise in the course I took in numeric programming in the summer of
1967 was an algorithm that was guaranteed to converge if the starting point was greater
than 1/2 the interval between two points...
Damn! You beat me! Mine was in October 1968. In the year when students across the channel were revolting and tearing down their universities, I was learning to write programs to invert 20x20 matrices (my first computer exercise) using fancy numerical methods in FORTRAN. I reckon I was missing out on something there.
Anyway: first instruction: call everything REAL*8 (=double). Last instruction: multiply the matix you first thought of by the one you got, and compare with the unit matrix to see what accuracy was achieved! (Fussy buggers, these numerical maths lecturers!)
..
Note that if you do not handle these properly, your Jupiter probe will miss the planet by
several million miles.
Well if you mix up feet and metres, then you can get a even bigger error crash into he surface of Mars - chacun a son gout, as far as errors are concerned :-)
Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm
.
- Follow-Ups:
- Re: Precision issue with Float and Double (C++)
- From: Joseph M . Newcomer
- Re: Precision issue with Float and Double (C++)
- References:
- Re: Precision issue with Float and Double (C++)
- From: Joseph M . Newcomer
- Re: Precision issue with Float and Double (C++)
- Prev by Date: Re: Precision issue with Float and Double (C++)
- Next by Date: Re: ctrl+V in CComboBox
- Previous by thread: Re: Precision issue with Float and Double (C++)
- Next by thread: Re: Precision issue with Float and Double (C++)
- Index(es):
Relevant Pages
|