Boost logo

Boost :

Subject: Re: [boost] [rational] Which way should std::numeric_limits::min go?
From: John Maddock (john_at_[hidden])
Date: 2013-08-22 03:18:06


> The static member function "min" has a defect. The function "denorm_min"
> returns the smallest positive value that can be represented (denormalized
> or not), and is implemented only for floating types. The function
> "lowest," new to C++11, returns the regular (i.e. not Infinity or NaN,
> etc.) value closest to negative-infinity. Lowest was introduced because
> for C++98/03, "min" returned "denorm_min" for the built-in floating types
> and "lowest" for built-in integer types! You can't get generic code out
> of that (without checking some more flags from numeric_limits).
>
> Which version of "min" should boost::rational take? I was think of
> "denorm_min," since I'll be implementing that. The built-in integer types
> use "lowest" for "min," but don't define the other one at all.

I would treat it as a variant of the integer types, and set min() to the
most negative value, and max() to the most positive value. I suppose
denorm_min could be the smallest positive value, but I don't think there's
any prior art for that.

HTH, John.


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