Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-10-19 13:04:23


How can we determine the minimum representable value of a built-in type?

18.2.1.2 numeric_limits members
static T min() throw();
1 Minimum finite value. 181)
2 For floating types with denormalization, returns the minimum positive
normalized value.
3 Meaningful for all specializations in which is_bounded != false, or
is_bounded == false && is_signed == false.

Is it guaranteed that the minimum representable value for floating types
with denormalization is -numeric_limits<T>::max()?

If not, I think we have a defect.

If so, the rules are complicated, but it should be possible to follow them.
To follow rule #2, we need to determine if the type has denormalization.
But:

18.2.1.2 numeric_limits members 18 Language support library
static const float_denorm_style has_denorm;
40 denorm_present if the type allows denormalized values (variable number of
exponent bits) 195) , denorm_absent if the type does not allow denormalized
values, and denorm_indeterminate if it is indeterminate at compile time
whether the type allows denormalized values.

What if has_denorm is denorm_indeterminate? Maybe the answer is:

numeric_limits<T>::is_signed && numeric_limits<T>::min() >= 0
? -numeric_limits<T>::max() : numeric_limits<T>::min()

-Dave


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