Topic: Q: numeric_limits<T>::min()


Author: elron@alum.mit.edu (Elron A. Yellin)
Date: 1998/02/14
Raw View
Why does numeric_limits<float>::min() return the minimum, positive,
non-zero (normalized) representable value while numeric_limits<long>::min()
returns the minimum representable value?
It would be nice if min() always returned the minimum (finite value) and a
separate member, min_pos_value(), was provided.

Thank you,
Elron


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: ncm@nospam.cantrip.org (Nathan Myers)
Date: 1998/02/16
Raw View
Elron A. Yellin<elron@alum.mit.edu> wrote:
>Why does numeric_limits<float>::min() return the minimum, positive,
>non-zero (normalized) representable value while numeric_limits<long>::min()
>returns the minimum representable value?
>It would be nice if min() always returned the minimum (finite value) and a
>separate member, min_pos_value(), was provided.

This may not be a good enough answer, but ...

The ISO Standard for Language Independent Arithmetic specifies
it that way, as does the C header <limits.h>.  Maybe it was wrong
to propagate the error, if error it was, but nobody who worked on
the <limits> header felt confident to second-guess the experts in
this area.

--
Nathan Myers
ncm@nospam.cantrip.org  http://www.cantrip.org/



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]