Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2006-02-10 09:33:16


 

| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of Victor A.
| Wagner Jr.
| Sent: 10 February 2006 06:08
| To: boost_at_[hidden]; boost_at_[hidden]
| Subject: Re: [boost] Boost test - displaying float point numbers
|
| 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

>From formula given by Kahan, inventor of IEEE754, so he should know!

http://http.cs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF

Page 4

and this was proposed

http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf

and found favour with WG14 so may well be part of TR2.

Note that the number of digits required to show all possibly significant
digits

which I have called max_digits10 (and

and as max significant digits MACROs for C N1151 to WG14

FLT_DIG 6, FLT_MAXDIG10 9
DBL_DIG 15, DBL_MAXDIG10 17
LDBL_DIG 19, LDBL_MAXDIG10 21

is 2 or 3 more than numeric_limits<>::digits10 which is effectively the
numerb that are guranteed correct - after being rounded.

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

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