Re: This calculation is just wrong / computer can't count!
- From: "GT" <ContactGT_remove_@xxxxxxxxxxx>
- Date: Thu, 4 Oct 2007 22:44:14 +0100
"Luke alcatel" <luke@xxxxxxxxxxx> wrote in message
news:uyM7l$pBIHA.4476@xxxxxxxxxxxxxxxxxxxxxxx
I'll risk criticism by saying this thread is silly. A middle school child
learns not to express calculation results with more significant digits
than the data or instruments provide. A double provides 14-15 significant
digits so why are you surprised that the result is not what you
theoretically expect at the 15th digit?
I am surprised because I am using a C++ basic data type and it shouldn't
stumble over basic mathematics!
Clue #1 adjust your print formats for fewer significant digits.
This number is the first stage in some complex calculations and the problem
is compounded resulting in a final number that is just wrong.
Clue #2 don't try to land on Jupiter if your flight control software uses
doubles but your navigation system requires 18 significant digits.
I only require about 5 or 6 decimal places, but float and double both see
the same problem, so what am I supposed to do?
Clue #3 find an arbitrary precision math library on the web and use it.
I found one - its called the basic C++ data types. int, float, double etc.
Why is everyone having a go at me? I asked a perfectly simple question that
is confusing 3 of us here. In front of me, I have a casio calculator, a
pencil and paper and a PC. I type some numbers into the calculator and
scribble on the paper and derive 5 numbers. The first stage in the
calculation is 25/30. The calculator gives us range of 5 number that
match/confirm what we worked out on paper, but the PC gives us something
else that is just wrong. We are not working on a low level C system here, we
are writing an MFC application with dialog boxes, menus and the likes. There
is not a printf in sight.
One of the results should be exactly 0, but the computer gives the
result -0.00000000007. Which is then displayed on the screen as -0.0. This
result is displayed on the screen (in an edit boxes) along with all the
positive numbers and is just wrong!
25/33 = 0.833 recurring. 0.833337 is not *innacurate* it is *WRONG*. End of
story.
Even if this 0.83333..3337 were true, then adding 1.0 to it CANNOT BE
1.8333...335 - it has changed the last digit!!! If it can't handle the last
digit, then it shouldn't display/use it.
If the computer can work to 8, 12, 15, 16, 18 digits, then why does it get
the last digit wrong?
I understand all this significant digit stuff, my problem is - Why does the
computer store and use the 'dodgy' last digit if it is actually WRONG and
causes incorrect results?
.
- Follow-Ups:
- Re: This calculation is just wrong / computer can't count!
- From: Geoff
- Re: This calculation is just wrong / computer can't count!
- From: Geoff
- Re: This calculation is just wrong / computer can't count!
- From: Geoff
- Re: This calculation is just wrong / computer can't count!
- From: Geoff
- Re: This calculation is just wrong / computer can't count!
- From: Joseph M . Newcomer
- Re: This calculation is just wrong / computer can't count!
- From: Les
- Re: This calculation is just wrong / computer can't count!
- References:
- This calculation is just wrong / computer can't count!
- From: GT
- Re: This calculation is just wrong / computer can't count!
- From: AliR \(VC++ MVP\)
- Re: This calculation is just wrong / computer can't count!
- From: GT
- Re: This calculation is just wrong / computer can't count!
- From: Luke alcatel
- This calculation is just wrong / computer can't count!
- Prev by Date: Re: PostThreadMessage and Lost Messages
- Next by Date: Re: This calculation is just wrong / computer can't count!
- Previous by thread: Re: This calculation is just wrong / computer can't count!
- Next by thread: Re: This calculation is just wrong / computer can't count!
- Index(es):
Relevant Pages
|