Topic: Numeric Limits
Author: "David Sachs" <sachs@fnal.gov>
Date: Wed, 6 Mar 2002 21:01:33 GMT Raw View
The C++ standard does not say anything about the usability of the values
returned by the numeric_limits classess. In particular, there is no
requirement that the expressions:
1./numeric_limits<double>.min()
1./numeric_limits<double>.max()
1.f/numeric_limits<float>.min()
1.f/numeric_limits<float>.max()
have meaninful values. This, perhaps, should be addressed in a future
version of the standard.
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: Thu, 7 Mar 2002 03:50:49 GMT Raw View
David Sachs wrote:
>
> The C++ standard does not say anything about the usability of the values
> returned by the numeric_limits classess. In particular, there is no
> requirement that the expressions:
>
> 1./numeric_limits<double>.min()
> 1./numeric_limits<double>.max()
> 1.f/numeric_limits<float>.min()
> 1.f/numeric_limits<float>.max()
>
> have meaninful values. This, perhaps, should be addressed in a future
> version of the standard.
The standard is deliberately written to not mandate the representation
of floating point numbers, in order to give implementors the freedom to
implement C++ on unusualy platforms. What would you have the standard
say, that won't unduly constrain the implementation? Consider
T product = numeric_limits<T>.min() * numeric_limits<T>.max();
If product > 1.0, then T(1.0)/numeric_limits<T>.max() can underflow,
though it may be denormalized if
numeric_limits<T>.has_denorm!=denorm_absent.
If product < 1.0, then T(1.0)/numeric_limits<T>.min() can overflow,
though it should be numeric_limits<T>.infinity() if
numeric_limits<T>.has_infinity is true.
I'm not certain, but I don't think it's possible for anything remotely
similar to ISO/IEC floating point, to have product==1.0, so you have to
have either one problem, or the other.
---
[ 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://www.research.att.com/~austern/csc/faq.html ]