[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 83

 
Geowind64:

Roman, thanks for the reply..... Unfortunately, I still don't understand one thing. In the textbook, https://book.mql4.com/ru/basics/expressions, under "Type Adduction. Option 4.1. Calculating the result of an integer type

and Variant 4.2. A similar situation occurs when looking for a result as a value of a real type", the same formula is given, but in one case, the type of the variable F is denoted as int

and in the second example, the variable is double

Unfortunately, I still don't understand the logic of the conversion. If in the first variant it is clear why int is assigned to variable F (i.e., according to rule of implicit type conversion), then why double.... is assigned in the second variant totally confuses me.

Please clarify what I may have missed in my explanations here?

Thanks in advance.

Well, there are rather complex things describing the peculiarities of the compiler's work which are not really needed in practice. They can be safely skipped.

The only thing we have to take out of it

  • if an expression contains operands of different types, the type of expression is converted to the type with higher priority; the types int, bool, color and datetime have equal priority, the type double - higher priority, the type string - the highest priority;
  • if the type of the expression to the right of the assignment operation sign does not match the type of the variable to the left of the assignment operation sign, then the value of the expression is cast to the type of the variable to the left of the assignment operation sign; this is called a cast to target type;
  • conversion of string values to any other target type is forbidden.

As for the examples, simply write the types

int = double + int (All you're saying is that int to the right of the plus sign is converted to double, then the operands are summed and then the result is converted to the type of the variable being assigned)

double = double + int (about the same, only without the last conversion, double is immediately assigned)

 
Roman.:

Guys, what does #INF mean - is it out of allowed range of double? see the second line from the top (it counts the product of double TWR, namely its previous value is multiplied by the next one). How to correctly count THOSE values taken by TWR variable?

I wonder. May #INF appear one day instead of balance too? :) :) :)

 
Roman.:

Guys, what does #INF mean - is it out of allowed range of double? see the second line from the top (it counts the product of double TWR, namely its previous value is multiplied by the next one). What is the correct way to count THOSE values taken by TWR variable?

infinity... can only be treated by reducing the appetite, TWR values are too big.
 
splxgf:
infinity is infinity... is only cured by reducing the appetite, the TWR values are too high.

Oh, really?

Some Smarties don't go around the mountain, they go the other way round, only uphill and uphill! :)))))

 
MaxZ:

I wonder. Could #INF ever appear instead of balance too? :) :) :)


Not funny. I'd rather have something to do...

 
splxgf:
This is infinity... can only be treated by reducing the appetites, TWR values are too high.


What to do?

see here - it's all right there, all by the book... All the appetites are strictly in line with R. Vince's methodology.

 
Roman.:


Not funny. You'd better get to the point...

I wrote my suggestion on the previous page.

 
Roman.:


What to do?

see here - it's all right there, all by the book... All the appetites are strictly in line with R. Vince's method.


Maybe in the week I'll think of a better way to do it. But busy with my task most of my free time.
 
Vinin:

Maybe in the week I'll think about the best way to do it. But busy with my task most of my free time.

Thank you, Victor.
 
MaxZ:

I wrote my suggestion on the previous page.


Sorry, didn't notice... :-)))

I checked it several times - there are no errors, everything is strictly according to the formulas.

Apparently, it is necessary to divide the product into parts and then compare them... Read more here.

Reason: