handling T.min the right way
Lionello Lunesu
lionello at lunesu.remove.com
Mon Mar 19 13:01:10 PDT 2007
"Andrei Alexandrescu (See Website For Email)"
<SeeWebsiteForEmail at erdani.org> wrote in message
news:45FEE0BC.4000407 at erdani.org...
>A while ago, C++ did the mistake of defining std::numeric_limits<T>::min()
>with a different semantics for floating-point types than for integral
>types. That hurt generic numeric code a lot.
>
> D has taken over the same mistake: T.min means the smallest value of the
> type, except for floating-point types, where it means the smallest
> positive value.
>
> The right way is to have T.min always return the minimum value (duh) and
> define a separate property T.min_positive.
Isn't this value sometimes also called "epsilon"? I think double.epsilon
sounds quite nice :)
L.
More information about the Digitalmars-d
mailing list