Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2007-12-01 11:23:39


>-----Original Message-----
>From: boost-bounces_at_[hidden]
>[mailto:boost-bounces_at_[hidden]] On Behalf Of Noah Roberts
>Sent: 30 November 2007 21:58
>To: boost_at_[hidden]
>Subject: [boost] units: need limits
>
>std::numeric_limits needs to be implemented for quantity.

Indeed where possible, std::numeric_limits needs to be implemented for ALL types.

> I think this should work:
>
>namespace std
>{
> template< typename T, typename U >
> class numeric_limits< boost::units::quantity<U, T> > : public
>numeric_limits<T>
> {
> typedef numeric_limits<T> type_limits;
> typedef boost::units::quantity<U, T> qty;
> public:
> static qty denorm_min() { return qty(type_limits::denorm_min() *
>U()); }
> static qty epsilon() { return qty(type_limits::epsilon() * U()); }
> static qty infinity() { return
>qty(type_limits::infinity() * U()); }
> static qty max() { return qty(type_limits::max() * U()); }
> static qty min() { return qty(type_limits::min() * U()); }
> static qty round_error() { return
>qty(type_limits::round_error() *
>U()); }
> static qty quiet_NaN() { return
>qty(type_limits::quiet_NaN() * U()); }
> static qty signalizing_NaN() { return
>qty(type_limits::signaling_NaN() * U()); }
> };
>}

What about the has_* things like has_infinity?

Should these be 'propagated'?

One might use NTL RR arbitrary precision for example with units, or even an integral type, for which some of these things are not
defined - and difficult to define? (Actually it would nice if someone could implement units for NTL or implement a higher precision
floating point type with limits).

Paul

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