
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Noah Roberts Sent: 30 November 2007 21:58 To: boost@lists.boost.org 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@hetp.u-net.com