Re: Precision problem in VBasic 6
From: Rick Rothstein (rickNOSPAMnews_at_NOSPAMcomcast.net)
Date: 02/04/05
- Next message: David Youngblood: "Re: Still need help on Rich Text Box"
- Previous message: Roger Hunt: "Re: Changing Computers' Times Down to the Millisecond"
- In reply to: Demetrios Panayotakopoulos: "Re: Precision problem in VBasic 6"
- Next in thread: Lee Peedin: "Re: Precision problem in VBasic 6"
- Reply: Lee Peedin: "Re: Precision problem in VBasic 6"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 4 Feb 2005 12:09:47 -0500
> BUT, that what I expect is, no matter how this is done, the result
should be
> accurate in this level of precision.
> Forgive me, but I really believe that this is ridiculous.
> ( -0.7-0.1= -0.8000001)
Given that
Print (1 / 3) ==> 0.333333333333333
it is no more so ridiculous than this result
Print (1 / 3) + (1 / 3) ==> 0.666666666666667
When a number cannot be represented with the limits of precision of the
math being used, some kind of approximation must be used somewhere.
> (by the way if you do the same calculations on a simple calculator you
will
> get the correct answer)
Calculators are fooling you. They use something called "guard digits" to
protect the integrity of the display. What this means is that a
calculator calculates to more significant digits than it displays. That
way, any errors that accumulate will be flushed out when the answer is
rounded to the number of digits that calculator actually displays. Think
of this process as using a Double data type, but always rounding your
answers to, say, 12 significant digits (note I said digits, not decimal
place).
Rick - MVP
- Next message: David Youngblood: "Re: Still need help on Rich Text Box"
- Previous message: Roger Hunt: "Re: Changing Computers' Times Down to the Millisecond"
- In reply to: Demetrios Panayotakopoulos: "Re: Precision problem in VBasic 6"
- Next in thread: Lee Peedin: "Re: Precision problem in VBasic 6"
- Reply: Lee Peedin: "Re: Precision problem in VBasic 6"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|