I figured.
It's by design. NaN is unequal to everything,also to itself, by definition.
Behavior depends on how compiler generates math with doubles. There are two models Fast and Precise.
MQL uses Precise model, it means each double comparison takes 3 CPU instructions: 1 compare and 2 conditional jumps (first jump if condition is not true, second jump if NaNs detected)
Fast model is only one jump - if condition is true, so this model does not detect NaNs and expression (x==Nan && x!=Nan) is true
MQL uses Precise model, it means each double comparison takes 3 CPU instructions: 1 compare and 2 conditional jumps (first jump if condition is not true, second jump if NaNs detected)
Fast model is only one jump - if condition is true, so this model does not detect NaNs and expression (x==Nan && x!=Nan) is true
Because that identity is not fulfilled, we have MathIsValidNumber() and MathClassify() to detect NaNs
Ilyas #:
Behavior depends on how compiler generates math with doubles. There are two models Fast and Precise.
MQL uses Precise model, it means each double comparison takes 3 CPU instructions: 1 compare and 2 conditional jumps (first jump if condition is not true, second jump if NaNs detected)
Fast model is only one jump - if condition is true, so this model does not detect NaNs and expression (x==Nan && x!=Nan) is true
Behavior depends on how compiler generates math with doubles. There are two models Fast and Precise.
MQL uses Precise model, it means each double comparison takes 3 CPU instructions: 1 compare and 2 conditional jumps (first jump if condition is not true, second jump if NaNs detected)
Fast model is only one jump - if condition is true, so this model does not detect NaNs and expression (x==Nan && x!=Nan) is true
Good to know this info.
Thanks
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
I just came accross an interesting effect and wanted to know why this is so.
I am not sure if this is considered a bug, but here is the code to reproduce:
The output will only be "TRUE4"
Why is this so, shouldnt they be eqal?