|
Boost : |
From: Victor A. Wagner Jr. (vawjr_at_[hidden])
Date: 2006-02-10 01:08:27
At 15:19 2006-02-09, Paul A Bristow wrote:
>Some of you have noted (with displeasure) the ugly display of floating point
>values from
>
>BOOST_CHECK_CLOSE
>
>for example
>
>difference between +1e-6{9.9999999999999995e-007} and
>1e-5{1.0000000000000001e-005} exceeds 2.22045e-018%
>
>The number of decimal digits used is enough to show all that can be
>significant.
>
>For 64-bit doubles it is 17 decimal digits, (for 32-bit float 9) and for
>long double, quad_float even more.
I don't see where you're getting your # of digits
my calculations show that it's around 14 for 64bit floating and
around 7 for 32bit
numeric_limits<>::digits10 shows 6 for float, 15 for double on vc8
>This is undoubtedly ugly, but has the virtue that it avoids apparently
>nonsensical displays like
>
>1.000000 != 1.000000
>
>when comparing 1.f, with the next after, one least significant bit above
>1.00000012f,
>
>which is what you get if the standard 6 decimal digits for float is used.
>
>It has another great virtue - it highlights the limitations of storing
>decimal representations in binary.
>
>There are smarter algorithms for display (which Gennadiy is considering),
>but IMO this is the C++ standard way of doing these things and I suggest
>that this is the Right Thing To Do in this case.
>
>Are there any dissenting views?
>
>Paul
>
>--
>Paul A Bristow
>Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
>Phone and SMS text +44 1539 561830, Mobile and SMS text +44 7714 330204
>mailto: pbristow_at_[hidden] http://www.hetp.u-net.com/index.html
>http://www.hetp.u-net.com/Paul%20A%20Bristow%20info.html
>
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Victor A. Wagner Jr. http://rudbek.com
The five most dangerous words in the English language:
"There oughta be a law"
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk