Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2004-07-26 15:34:37


 

| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of Victor A.
| Wagner Jr.
| Sent: 26 July 2004 19:53
| To: boost_at_[hidden]
| Subject: Re: [boost] Unit test could usefully output more
| significantdigits to log files?
|
| >In test_tools.hpp, I have added an increase to the ostream precision
| >(default only 6 digits) int print_log_value thus
| >
| > template<typename T>
| > struct print_log_value {
| > void operator()( std::ostream& ostr, T const& t )
| > {
| > if(std::numeric_limits<T>::is_specialized &&
| >std::numeric_limits<T>::radix == 2)
| > { // Show all possibly significant digits (for example,
| 17 for 64-bit
| >double).
| > ostr.precision(2 + std::numeric_limits<T>::digits * 301/1000);
|
| is there some reason you didn't:
| ostr.precision(2 + std::numeric_limits<T>::digits10);
| instead of estimating log(2)? (301/1000)
|

Yes - it was to get all possibly significant digits, rather than all
guaranteed.
You need to estimate log2 because the compiler won't do the necessary fp
calculations.

Sometimes this is more helpful - and since this a diagnostic, it seemed a
little better.

However digits10 would also be much better than default 6 precision.

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