How to Assign a Very Small Number to a Double

 

I want to declare the following:

double positiveInfinity = 1.7e308;

double negitiveInfinity = -1.7e-308;

double value = 1.1e-134;

According to the documentation a double can ranges from -1.7 * e-308 to a positive 1.7 * e308 but when I try

double value = 1.1e-134; // '1.1e' - invalid number

double value = 1.1E-134; // '1.1E' - invalid number

double value = 1.1 e-134; // 'e' - variable not defined

double value = 1.1 * e-134; // 'e' - variable not defined

I get errors, however, it works just fine in Microsoft Excel, C, C++ etc. -- is this a bug in the lexical analyzer/compiler?! If so, how do I work around it until it is fixed?

 

1.1 * MathPow(10,-134);

 
blogzr3 wrote >>

1.1 * MathPow(10,-134);

Thanks, from this I was able to create the following four functions:

double _positiveInfinity;
double _maxDouble;

double PositiveInfinity()
{
    if (_positiveInfinity == 0)
        _positiveInfinity = MathPow(10, 309);

    return (_positiveInfinity);
}

double NegativeInfinity()
{
    return (-PositiveInfinity());
}

double MaxDouble()
{
    if (_maxDouble == 0)
        _maxDouble = 1.7 * MathPow(10, 308);

    return (_maxDouble);
}

double MinDouble()
{
    return (-MaxDouble());
}

The PositiveInfinity() and NegativeInfinity() functions actually return 1.#INF0000 and -1.#INF0000 and adding or subtracting from infinity doesn't do any thing (as expected) but subtracting from MaxDouble() or adding to MinDouble() does work (also as expected).

I wish there was a way to represent 'Not a Number" (NaN) ... any ideas?

 
What will you do with this?