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
Needed to determine the size of a variable array, but the error comes out:
//---
//---
It works directly with constants (#define) and with a numeric value, but not like this. Why?
Needed to determine the size of a variable array, but the error comes out:
//---
//---
It works directly with constants (#define) and with a numeric value, but not like this. Why?
tol64:
Why?
With constants (#define) and with a numeric value, it works directly, but not like this. Why?
Because when defining with #define, the compiler simply replaces the macro encountered with the correct entry before compilation. Therefore it sees
that does not contradict the MQL5 language.
OK. Then I'll take the nerve. So, the description of the Print() function says that "data of the double type are printed with the precision of 16 decimal digits after the point". In fact, it turns out that the Print() function outputs somewhat rounded data:
MP 0 victorg2 (EURUSD,M1) 11:04:42 Print(DoubleToString(b,16))=199.999999999999999716
The point is that a real number is stored in memory with no more than 17 significant digits.
Try this example to feel the difference:
The description in the help will be corrected.With constants, it is a static array, and with a variable, it is dynamic. And the size of a dynamic one is determined using ArrayResize.
The second and subsequent dimensions have a fixed size. It can only be set by a constant.
Because when defined with #define, the compiler simply replaces the macro encountered with the correct entry before compilation. Therefore it sees
that does not contradict the MQL5 language.
Thank you. Can you tell me what can be done if the size of an array in both the first and second dimension is determined by calculations and cannot be a constant? With ArrayResize(), you can only change the size of the first dimension. And why can you resize an array using a variable, while it cannot be set initially?
Thank you. Can you tell me what can be done if the size of an array in both the first and second dimension is determined by calculations and cannot be a constant? With ArrayResize(), you can only change the size of the first dimension. And why can I resize an array by applying a variable value, while it cannot be set initially?