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
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?