Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-03-16 09:18:11


> | 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.

> 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

> 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?

There is still an open issue how to use numeric_limits in generic function.
Any ideas?

I guess I could use is_float, but then I cut any UDT that does specialize
numeric_limits.

Gennadiy


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