Is it possible to get an "exact" value? - page 6

 
abolk:

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?)

 
sanyooooook:

0.09*5=0.45 )

You don't know how to count, do you?)

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.
 
sanyooooook:
because it is common in mathematics that if the number of decimal places is to be removed, the value is rounded.
miudro
 
Thank you for your help.
 
always
 
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 :).
 
Rounding up is easier
 
abolk:

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:

Normalize ("0.01999999999999999999999999999999", 6)

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.

 
WePlexus:

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.

Reason: