That's right, I gave an example that counts 0.44 instead of 0.45 because of "its" work in MQL. I'm not familiar with the language, but it's strange, why a big number gets clipped, I mean why, when it exceeds the limit, it gets rounded but not clipped. It would be great if the "exact string trimming" method, maybe the one I cited above, was in MQL for use. :)
WePlexus: That's right, the example was given that it counts 0.44 instead of 0.45 because of "its" work in MQL. I don't know the language thoroughly, but it's weird why a big number gets clipped, I mean, why when the number goes over the limit, it gets rounded instead of being clipped. It would be great if the "exact string trimming" method, maybe the one I cited above, was in MQL for use. :)
because it's common in mathematics, if the number of decimal places needs to be removed, then the value is rounded.
WePlexus: I don't know the language thoroughly, but it's weird why a big number gets clipped, I mean, why when the number goes over the limit, it gets rounded off instead of being clipped. It would be great if the "exact string trimming" method, perhaps the one I cited above, was in MQL for use. :)
That's how I understood how "exact trimming" could be useful. Well, apart from a sense of satisfaction and legitimate pride from a solved problem :).
There are several ways to solve your problem -- each of them has its advantages and disadvantages -- in terms of accuracy and speed of getting the result.
Working with floating numbers has its own peculiarities -- you have to understand them -- and to understand these peculiarities + for your problem -- you have to look for a solution.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
To solve this problem, 0.09*5 has to be =0.45, not =0.44999999999999999
and if it doesn't exist, the problem is unsolvable.
0.09*5=0.45 )
don't you know how to count?)
0.09*5=0.45 )
You don't know how to count, do you?)
That's right, the example was given that it counts 0.44 instead of 0.45 because of "its" work in MQL. I don't know the language thoroughly, but it's weird why a big number gets clipped, I mean, why when the number goes over the limit, it gets rounded instead of being clipped. It would be great if the "exact string trimming" method, maybe the one I cited above, was in MQL for use. :)
because it is common in mathematics that if the number of decimal places is to be removed, the value is rounded.
I don't know the language thoroughly, but it's weird why a big number gets clipped, I mean, why when the number goes over the limit, it gets rounded off instead of being clipped. It would be great if the "exact string trimming" method, perhaps the one I cited above, was in MQL for use. :)
this is the maximum number at which normalisation takes place:
If you take one more 9, it normalises to 0.02.
But my function does the job:
It outputs 0.019999. Then you can convert the number to the right type and do math with it.
If you pass a number into the function without quotes, the result will be 0.02.
There are several ways to solve your problem -- each of them has its advantages and disadvantages -- in terms of accuracy and speed of getting the result.
Working with floating numbers has its own peculiarities -- you have to understand them -- and to understand these peculiarities + for your problem -- you have to look for a solution.