Double Limit
-
HI. I have alwasy assumed for some bad reason that DBL_MIN means the minimum value for a double. But it is actually the minimum position number. I was wondering is there a CONSTANT that holds the minimum double (negative) number? Thanks in advance.
-
HI. I have alwasy assumed for some bad reason that DBL_MIN means the minimum value for a double. But it is actually the minimum position number. I was wondering is there a CONSTANT that holds the minimum double (negative) number? Thanks in advance.
First include
<limits>
. Now get minimum like this:-std::numeric_limits<double>::max();
Steve
-
First include
<limits>
. Now get minimum like this:-std::numeric_limits<double>::max();
Steve
DO I also need to do something else? It says that std is not a namesapce etc. THanks for the help.
-
DO I also need to do something else? It says that std is not a namesapce etc. THanks for the help.
Just have to make sure you have this line in the file:
#include <limits>
Steve -
DO I also need to do something else? It says that std is not a namesapce etc. THanks for the help.
For strict ANSI you should only use and assume the the most negative double representable is -DBL_MAX (the negative of DBL_MAX). This will result in -1.7976931348623158e+308, which is, in fact the most negative number that can be represented. This assumption is reasonable since the sign bit can always be used to represent any negative form of any positive number and vice-versa. Note, however, that the "resolution" is only of about 15 digits. This means that 10e20 + 1.0 will result in 10e20. And you can keep adding 1.0 and the result will never change from 10e20. So, it is important to note the difference between dynamic range (308 exponent) and resolution (about 15 decimal digits). Rilhas