Errors, bugs, questions - page 2208
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
The famous job interview question.
What will be in the i ?
MQL5 outputs 12. MS Visual Studio outputs 13.as it seems to work in C++. That's why I asked, decided to read C++ for example. Same value by one just in difference. It seems to assign 5 to "y" in second case and then add it, while in first example it first adds and then assigns (it took me a long time to figure out how it works =D )
In mql5 they are equal operations, in c++ they are different, below you have just an example of a test on c++ ))
The famous job interview question.
What will be in the i ?
MQL5 gives out 12. MS Visual Studio gives out 13.Undefined because of the side effect. In this case, a triple effect altogether. Different optimizations may calculate variable values differently. For the sake of optimisation.
In mql5 they are equivalent operations, in c++ they are different, below you were just given an example of a test on c++ ))
Where did you get it from? Did you compare results of operations array[++i]=i and array[i++]=i?
Here's a puzzle for you. What is the difference between postfix operation and prefix operation?
A famous question in a job interview.
A dumb, unnecessary question that only reveals whether the interviewee knows what UB is and has little to do with the topic of discussion.
Aleksey Rodionov:
I'm sitting here thinking, how can the code of prefix form come in handy?
The compiler has enough brains to optimize the postfix form when needed.
Where did you get the input from? Have you compared results of operations array[++i]=i and array[i++]=i?
Here's a puzzling question. What is the difference between postfix operation and prefix operation?
what does array[++i]=i and array[i++]=i have to do with it, how can I compare what hasn't been in the conversation...
If there are some changes in mql in the framework of the dispute and you know about it, then you as a moderator are obliged to inform the participants of the dialogue, instead of trying to do the syntax knowledge tests, it's definitely not your duty ...
and moreover, show all the instructions in mql help about the difference in postfix and prefix operations, but the tests of previous years show that these operations were equivalent in mql
ps. by the way, i just checked the example from the dialog
build 1816 result == 12
This is a dumb, unnecessary question, which reveals only whether the interviewee knows what UB is and has little to do with the topic of the discussion.
Well, actually the prefix form is faster.
Moreover, I believe that using such constructs in your code is just unacceptable.
First, because of the ambiguity of work in different implementations and, even more, because it's easy to make a mistake in such code and not so easy to make sense of it.
The code should be transparent and understandable at a glance.
Moreover, in my opinion, it is simply unacceptable to use such constructs in code.
Firstly, because of ambiguity of work on different implementations, and even more - because it is easy to make a mistake in such code, and not easy to understand.
The code should be transparent and understandable at a glance.
it's time to change the mql5 help to the form of language conventions and rules
What does array[++i]=i and array[i++]=i have to do with it, how can I compare what didn't happen in the conversation...
If there is a change in mql within the framework of the dispute and you know about it, then as a moderator you are obliged to bring it to the participants of the dialogue, instead of trying to conduct syntax knowledge tests, it's definitely not your duty...
and moreover, show all the instructions in mql help about the difference in postfix and prefix operations, but the tests of previous years show that these operations were equivalent in mql
ps. by the way, i just checked the example from the dialog
build 1816 result == 12
But your examples are purely theoretical. They are intended only for students. No programmer in his/her right mind would release them into production.
Postfix and prefix increment and decrement are actually used first of all in loops. And they are called increments and decrements!
Here are some examples
и
If you claim that prefix and postfix operations work the same way, then flag in your hands and drum on your neck.
In case of prefix increment, you will get an uninitialized null array element and an array out of range error at the last iteration.
PS. Decided to reread our documentation on this subject in green link https://www.mql5.com/ru/docs/basis/operations/mathoperation
Important note
int i=5;
int k = i++ + ++i;
You may have calculation problems when porting the above expression from one programming environment to another (for example, from Borland C++ to MQL5). In general case, the order of calculations depends on compiler implementation. In practice, there are two ways of implementation of postdecrement (postincrement):
In MQL5 we currently implement the first method of calculating the postdecrement (postincrement). But even with this knowledge, it is better not to experiment with using this trick.