Boost logo

Boost :

From: rogeeff (rogeeff_at_[hidden])
Date: 2001-12-19 03:52:42


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk