Get the number of decimal places of any numbers (not just quotes) bypassing Digits() in MQL4 and MQL5 - page 12
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
This is probably the best solution
it is not correct to compare doubles on equality, moreover, the task is to be exact to the sign
Look at the stdlib.mq4 file in MT4, there was an example of correct double comparison
CompareDoubles()
SZZ: here is an article on the subjecthttps://www.mql5.com/ru/articles/1561
I wonder how you'll do logarithms, exponentiation with non integer numbers, trigonometry, .... use third party libraries, indicators... They all have errors!
If you need super-mega precision, you can use special external libraries like gnu mp
Otherwise, if you need guaranteed accuracy (when at each operation error is calculated), you should use all sorts of "interval libs".
if even that is not enough - you can use polynomials instead of digits
but I've never seen such cases, when such circuits are really needed from MT:-)
there's a double for the eye :-)
it is not correct to compare doubles on equality, moreover, the task is to be exact to a sign
Look at the stdlib.mq4 file in MT4, there was an example of correct double comparison
CompareDoubles()
Well, well, and the runtime with CompareDoubles soars by a factor of 2. Then it's better this way:
Well, well, and the execution time with CompareDoubles soars by a factor of two. You'd better do it this way:
We are talking about correct calculation, I can't check your code now, but it's not difficult, you need to compare your example with an example using DoubleToStr() in the loop, if there is no difference, then everything is correct
ZS: I tried with fmod() I think I posted an example, it does not work correctly, like at 0.07 should check - immediately a bug popped up
We are talking about correct calculation, I cannot check your code now, but it's not hard, you need to compare your example with the example using DoubleToStr() in the loop, if there is no difference, then everything is correct
I have already checked it and calculated the speed and it is the best way. Unless you need to look for more than 7 characters, of course.
S.s. 0.7 and 0.07 and 500000000.0001, etc. all calculated correctly.
s.s. But for 500000000.9991, it handles worse. But it hardly matters in forex practice.
But in forex practice this is hardly important.
it depends on the problem. if it is for trade orders, then this problem is meaningless - prices are normalized to Digits, while lots are relative to the minimum lot
If the problem is with mathematical modeling, it may be useful.
it depends on the problem, if it is for trading orders, then this task is meaningless at all - prices are normalized to Digits, and lots are relative to the minimum lot
If the task is with mathematical modeling, it may be useful.
Of course, not to write neural networks =))) and say, it is convenient to store prices/lots/money as a 4-byte integer with decimal value, reducing data size by 2 times.
it is not correct to compare doubles on equality, moreover, the task is to be exact to a sign
Look at the stdlib.mq4 file in MT4, there was an example of correct double comparison
CompareDoubles()
SZZ: here was an article on the subjecthttps://www.mql5.com/ru/articles/1561
So the task is to determine by how many digits x is normalized. So it's OK. Unless you were too lazy to write such a ladder.
Unless you were too lazy to write such a ladder.
You can do it without a ladder, but it takes 10% longer.
You can do it without a ladder, but it takes 10% longer.
This one: f/=0.0000001; is questionable.