|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I want to ask about arithmetical operators.
1. It is written the following: A = B + C, with description that add A to B and assign the result to C. Is it mistake? The same with A = B - C. 2. And I do not understand A = A % C, with description: A is remider of division of B on C(ex: 10%2 will produce 0). I simple do not understand 10 % 2 = 0 and 10 % 3 = 1. May you explain? :confused: 3. It was mentioned that we can not write as: A=(B++)*5 we must write: :confused: A++; B=A*5 May be the following: B++; A=B*5 |
|
||||
|
The remainder operator
Quote:
A = B + C; "Add B to C and assign the result to A." A = B - C; "Subtract C from B and assign the result to A." I have updated the lesson , please donwload it Quote:
For example: 10%5=0 This is because if you divide 10 by 5 you will get 2 and there no remaining value, so the remainder is 0. 10%8=2 This is because if you divide 10 by 8 you will get 1 (1*8=8), so the remainder is (10-8 = 2). 100%15=10 This is because if you divide 100 by 15 you will get 6 (6*15=90), so the remainder is (100-90=10). What about 6%8? It will be 6 because if you divide 6 by 8 you will get 0 (8*0=0), so the remainder is (6-0=6). Quote:
So you can't write: A=(B++)*5; or B=(A++)*5; But you can write: A++; B=A*5; And B++; A=B*5; How is it work? Let’s take a live example: int A=1; //set A to 1 int B; A++; //increase A by 1, now A=2 B=A*5 //which means B=2*5 |
|
||||
|
Quote:
Let’s assume that A = 10 and B = 4 then A=10%4; //which will produce 2, so now A=2. Quote:
The Greater Than or Equal operator is ">=" (only one Angle bracket). Quote:
For example if we assumed A=5 and B=10 then: A+=B will equal to A=10+5 then A=15 now. |
|
||||
|
Quote:
Left shift is not a very interesting operation for traders. It's a binary operation used for system computing. For example if you have 32 (In binary = 00100000), and Left Shift it ... you get 00010000 (Move the numbers an item to the left). So ... you would get 16. As binary is a power of 2. Left Shift .... is very similar to divide a number by 2 Rigth Shift is very similar to multiply a number by 2. I tell 'very similar' because according to the way of store numbers and store the sign of the number ... it's not exactly the same. Anyway, you will never use it. Last edited by forexts : 10-31-2005 at 06:56 AM. |
|
||||
|
Operator %
Operator % = Remainder
Description taken from wikipedia. The remainder for natural numbers If a and d are natural numbers, with d non-zero, it can be proved that there exist unique integers q and r, such that a = qd + r and 0 ≤ r < d. The number q is called the quotient, while r is called the remainder. The division algorithm provides a proof of this result and also an algorithm describing how to calculate the remainder. Examples
|
|
|||
|
Ok. Now I understand.
We can not use our simple arithmetical knowledge. A += B is the A increasing on B. A -= B is A decreasing on B. A = B%C is the remainder from dividing B by C. And I think A /= B is A = A / B. And A = A + B is valid because it is not arithmetic. It is logic. |
|
|||
|
It is arithmetical operations but it is logic.
In arithmetic if A + B so it should be C already. It should not be the same A (the same value). Because if we are increasing A on B assigning the result to A so A will be increasing on B all the time. Every second A will be increasing on B without any stopping. It means A plus B is equal A (the same A?) so plus B once again (because of A plus B) is equal A (an other A) which should be added to B and so on. May be during the coding everything will be clear. But I have a question. In Relational operators A == Bi; It means true if A equal B else false. Is it necessary to have i after B? |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Lesson 3 - MQL4 Data types | codersguru | Lessons | 20 | 05-18-2007 03:55 AM |
| mql4 tutorial - Where is Lesson 1, etc.? | ftsdPadawan | Metatrader 4 mql 4 - Development course | 2 | 01-15-2007 08:36 PM |
| Lesson 8 - Variables in MQL4 | codersguru | Lessons | 11 | 09-15-2006 01:06 PM |
| Lesson 9 - Preprocessors | codersguru | Lessons | 7 | 05-18-2006 08:26 PM |
| Lesson 7 - Functions | codersguru | Lessons | 2 | 11-02-2005 03:32 PM |