is it posible to assign NaN to a variable of type double?
It looks like the helpfile explains that pretty clearly:
https://www.mql5.com/en/docs/math/MathIsValidNumber
- www.mql5.com
Yes it does it a bit:
"If the checked value is a plus or minus infinity, or "not a number" (NaN), the function returns false."
But how do assign:
1. minus infinity
2. plus infinity
3. NaN
to a double?
These 5 functions MathArcsin, MathLog10, MathArccos, MathSqrt and MathLog are able to return some of theme.
Your answer imply using theme and no constant or something else.
The wired thing is that EMPTY_VALUE is a Valid Number.
Thank you, I'll go for MathSqrt(-1)
- www.mql5.com
void OnStart() { double foo = double("nan"); Print(foo); }
Special double values:
double foo = double("nan"); double foo = double("inf"); double foo = double("-inf");
Example
if(condition) return result; else return double("nan");
A variable of type double is alway set. Can I assign it to NaN? - MathIsValidNumber() returning false?
doc Quote from: https://www.mql5.com/en/docs/basis/types/double
"Besides the minus infinity there is the plus infinity and NaN (not a number). To determine that this number is invalid, you can use MathIsValidNumber(). According to the IEEE standard, they have a special machine representation. For example, plus infinity for the double type has the bit representation of 0x7FF0 0000 0000 0000."
Beside the Compilation Warning: "truncation of constant value", the number is still valid!
Is the a way to assign an invalid value?