Re: Floating point precision problem
- From: David Wilkinson <no-reply@xxxxxxxxxxxx>
- Date: Wed, 12 Oct 2005 12:26:30 -0400
Victor Bazarov wrote:
How did you arrive at that number? Here is my example:
#include <iomanip> #include <iostream> using namespace std;
int main() { double db = 98653258.0002; double gg = 2569.003;
double qq = db + gg; double qqq = 98655827.0032; // expected
cout << setprecision(17) << qq << ' ' << (qq-qqq)/qqq << endl; }
Victor:
Actually, your program is incorrect. The internal representation of your "expected" qqq also has floating point errors in it, so your qq-qqq does not represent the true error in the calculated qq.
My confusion was that I took the calculated value 98655827.00320009 from the OP. The correct value, as Brian Muth pointed out, is 98655827.003200009.
David
.
- References:
- Re: Floating point precision problem
- From: Victor Bazarov
- Re: Floating point precision problem
- From: David Wilkinson
- Re: Floating point precision problem
- From: Victor Bazarov
- Re: Floating point precision problem
- Prev by Date: Re: Floating point precision problem
- Next by Date: Setting font for dialog frame - Japanese
- Previous by thread: Re: Floating point precision problem
- Next by thread: Re: Floating point precision problem
- Index(es):
Relevant Pages
|