Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2002-09-08 06:37:00


I've no problems with this, but I have some trouble foreseeing
new floating point types for which numeric_limits<>::digits IS
defined. Anyone who understands how to define this will
also likely see its implications for intervals constants?

Won't the whole thing crunch when the code gets to use this item?

Paul

> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]On Behalf Of Sylvain Pion
> Sent: Saturday, September 07, 2002 6:16 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] Formal Review for Interval Library- getting
> intervalsofconstants
>
>
> On Sat, Sep 07, 2002 at 11:13:20AM +0100, Paul A. Bristow wrote:
> > The drawback of this is that in practice you only need sparse handful of
> > intervals for significands numeric_limits<>::digits
> > = 23, 24, 32, 53, 64, 80, 106, 112, 128 perhaps.
> > So a switch, and perhaps some default, as Sylvain Pion
> suggested is quite
> > adequate.
>
> The template solution has advantages : it can simply refuse to
> compile if you
> try to ask a digits/radix pair of values which you have not planned.
> With the initial switch I proposed, you can only get a run-time error.
>
> The template solution is also more easily extensible as Herve
> said : you don't
> need to have only one big statement in only one file, you can spread the
> various versions over several files.
>
> So I guess you could write your constants like :
>
> template <class T, int radix = std::numeric_limits<T>::radix,
> int digits = std::numeric_limits<T>::digits>
> class pi;
>
> template <>
> class pi<float, 2, 24>
> {
> static const float upper = ...;
> static const float lower = ...;
> static const float nearest = ...;
> };
>
>
> Either you refuse to compile if the value is not planned, or you
> can have the
> template falling back on a lower precision available :
>
> template <class T, int radix, int digits>
> class pi {
> static const T upper = pi<T, radix, digits-1>::upper;
> ...
> };
>
> Seems reasonnable ?
>
> --
> Sylvain
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


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