Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2005-03-16 11:59:11


 

| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of Gennadiy Rozental
| Sent: 16 March 2005 14:18
| To: boost_at_[hidden]
| Subject: [boost] Re: Re: No tests on como?
|
| > | template<typename T>
| > | struct print_log_value {
| > | void operator()( std::ostream& ostr, T const& t )
| > | {
| > |
| set_log_precision<std::numeric_limits<T>::is_specialized &&
| > | std::numeric_limits<T>::radix == 2>::_( ostr );
| > |
| > | ostr << t;
| > | }
| > | };
| > |
| >
| > And for a UDT it relies on a specialization being provided for
| > numeric_limits.
|
| > For UDT you could provide your own specialization for print_log_value;
| > For example, for NTL, a popular collection of very high
| > precision types, no specialization is provided for numeric_limits.
|
| Well, then default one is going to be used.
Indeed, I have encouraged the author Victor Shoup, to specialise
numeric_limits for NTL.
|
| > And if radix is something funny like 10, this formula
| >
| > 2 + std::numeric_limits<T>::digits * 301/1000
| >
| > is wrong.
|
| As you could see above I apply this formula only if radix ==2

Agreed.
 
| > So I think you need a fall-back default precision.
| >
| > It could be the default 6,
|
| Are you saying that I need to set a precision to fixed value 6? Why?

Only that if T isn't specialized or radix != 2, then the stream default
precision will apply,
6 for floats,

unless it is changed elsewhere,
which might be helpful because it easily leads to
apparently nonsensical reports like

 1.23456 != 1.23456

(where the difference is smaller, perhaps only 1 least significant bit,
when you would might precision 17 to avoid a similar problem).

Perhaps a global MACRO value could allow users to chose?

For some, the clutter of 17 decimal digits would be intolerable -
they would rather put up with the "1.23456 != 1.23456" reports.

For others, seeing all the digits is essential to understanding the log.

Paul

Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
+44 1539 561830 +44 7714 330204
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