Error in the book with possible.mq4

 

Hey everyone,


am trying to learn the language of MQL4 (I'll get to MQL5 later)
have an issue with one of the programs in the book.

https://book.mql4.com/programm/samples

the program possible.mq4 has a floating-point type "double" in it.
But when running it, it only gives 4 digits after the dot,

instead of the 5 digits after the dot that the Currency USDCHF has.

I have tried to make a float of it, but that failed also.
Can someone explain to me why the result is different then the actual digits.


kind regards,

Th

Examples of Implementation - Program in MQL4 - MQL4 Tutorial
Examples of Implementation - Program in MQL4 - MQL4 Tutorial
  • book.mql4.com
As a rule, function descriptions are indicated in the same sequence as they are called for execution by the client terminal. Namely, first goes the description of init(), then start(), and the last one is deinit(). However, special functions are called for execution by the client terminal in accordance with their own properties. That is why the...
 

You have to understand the principle of double and floats and the difference in the way they exist an the way they are presented to you (most of the time in a rounded version by DoubleToString(..)) and why most of the comparisons of the equality of two double fails!

For example read this thread.

The second thing is to understand the decimal numbers of the prices. Practically every broker can do and does what he wants or what seems to be good for him. :(

Read for example this or that thread. "Decades ago" the prices had 4 decimals, just Yen had two, now most of them had 5 and Yen 3 decimals. Check the specs of your broker!!

Floating-point arithmetic - Wikipedia
Floating-point arithmetic - Wikipedia
  • en.wikipedia.org
In computing, floating-point arithmetic is arithmetic using formulaic representation of real numbers as an approximation so as to support a trade-off between range and precision. For this reason, floating-point computation is often found in systems which include very small and very large real numbers, which require fast processing times. A...