Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-08-20 10:20:53


| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]]On Behalf Of Daniel Spangenberg
| Sent: Tuesday, August 19, 2003 9:25 AM
| To: boost_at_[hidden]
| Subject: [boost] Re: Insufficient significant digits using lexical_cast
|

| I think, the correct solution would be the usage of a constant, similar to
| DECIMAL_DIG, which is provided from C99 on. 5.2.4.2.2 says:
|
| "— number of decimal digits, n, such that any floating-point number
| in the widest
| supported floating type with pmax radix b digits can be rounded to a
| floating-point
| number with n decimal digits and back again without change to the value,
|
| pmax log10 b if b is a power of 10
| Ceil(1 + pmax log10 b) otherwise
|
| DECIMAL_DIG 10"
|
|
| My personal opinion is: Extend the DECIMAL_DIG definition for any
| floating point type,
| similar to digits10

I agree (and indeed have previously and now suggested) that adding to
numeric_limits:: would be the best solution.

But for the time being to 'fix' lexical cast, I think my suggestion, perhaps
with Daryle's refinement to warn if not IEE754, is at least better than the
existing formula. I will make a further suggestion when I get a moment to test
it.

Paul

Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
mailto:pbristow_at_[hidden]


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