It looks like the helpfile explains that pretty clearly:
https://www.mql5.com/en/docs/math/MathIsValidNumber
Documentation on MQL5: Math Functions / MathIsValidNumber
- www.mql5.com
Math Functions / MathIsValidNumber - Documentation on MQL5
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)
Documentation on MQL5: Standard Constants, Enumerations and Structures / Named Constants / Other Constants
- www.mql5.com
Standard Constants, Enumerations and Structures / Named Constants / Other Constants - Documentation on MQL5
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");
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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?