Get the number of decimal places of any numbers (not just quotes) bypassing Digits() in MQL4 and MQL5 - page 2
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
Yes, eight.
Why then.
Digits_values returns 4 ?
Result: 500000000.0001:4
How many digits after the decimal point are there?
Apparently so many that the computer can't even count.
Result: ????
Why then
Digits_values returns 4 ?
Result: 500000000.0001:4
Study the string conversion.
How many digits after the decimal point are there?
Apparently so many that the computer can't even count.
Result: ????
Yeah, like 1/3.
A good solution usually works correctly
I may not have checked everything, but when I tested it twice on MQL4, the output values were correct
Study the cast to string.
What does this have to do with conversion? There is a source number 500000000.0001
The question is how many decimal places does it have? The answer is 4, and you have 8.
There is a source number 500000000.0001
There is no such number among the doubles. There is an approximate equal to it - 500000000.00010001016593933105. It is assigned to it.
What does this have to do with conversion? There is an initial number 500000000.0001
The question is how many decimal places it has? The answer is 4, and you have 8.
Not " you have 8", mql has 8 by default. Can't we read the documentation?
I think I am not the only one who had a rare situation where I needed to get the number of decimal places, and Digits() function works only with quotes, and besides there is no information about it anywhere (at least at the time of writing this post I have not found it before, so I want to show what solution I found).
As it turned out, the essence of the banal simple, but still has one drawback - this function does not recognize zeros, if after them there are no other digits. For example, the function will return 2 when followed by 0.01, but when followed by 0.0000 it will return 0 (i.e. it can't see four zeros). So, consider this shortcoming in your developments.
The code in MQL4
Aren't you a bit worried by the fact that your Value parameter is colored blue?
Aren't you the least bit bothered by the fact that you have the Value parameter in blue?
It is so here on the forum for some reason, but in the editor it is the same as usual