|
Boost : |
From: Paul A. Bristow (boost_at_[hidden])
Date: 2001-12-22 12:45:54
Is it simply that the calculation
|d3 - 11| / 11
also has some roundoff opportunities?
Or is this too naive a suggestion?
Paul
Dr Paul A Bristow, hetp Chromatography
Prizet Farmhouse
Kendal, Cumbria
LA8 8AB UK
+44 1539 561830
Mobile +44 7714 33 02 04
mailto:pbristow_at_[hidden]
> -----Original Message-----
> From: rogeeff [mailto:rogeeff_at_[hidden]]
> Sent: Wednesday, December 19, 2001 8:53 AM
> To: boost_at_[hidden]
> Subject: [boost] Re: Floating Point comparisons
>
>
> Hi,
>
> After some clarification I still got one confusing example:
>
> #include <iostream>
> #include <limits>
>
>
> int main()
> {
> double d = 11;
> d /= 10;
> d = d*d - d;
>
> d *= 100;
>
> std::cout << ((d - 11)/ d / std::numeric_limits<double>::epsilon
> () ) << std::endl;
>
> return 0;
> }
>
> Intent is to calculate some value and comapre it with the real value.
>
> so I did:
>
> d1 = 11/10 - 1 rounding error
> d2 = d1*d1 - d1 - 2 rounding errors
> d3 = d2 * 100 - 1 rounding error
>
> The resulting value should be again 11. Now I calculate relative
> rounding error between resulting value and real value. It expected
> do not exceed (1+2+1)*1/2 * epsilon = 2 * epsilon. So expected that:
>
> |d3 - 11| / 11 <= 2* epsilon
>
> or
>
> |d3 - 11| / 11 / epsilon <= 2
>
> While I am getting from MSVC is ~4.
>
> What could it be?
>
> Gennadiy.
>
>
>
> Info: http://www.boost.org Send unsubscribe requests to:
> <mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk