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 because it is 0.6, so 0.5 is only obtained by cheating.
If 'v1' is inserted in any number, then it shows that it is rounded correctly to 'i = 2'.
If 'v1' is inserted in any number, then you can see that up to 'i = 2' everything is rounded correctly.
When only one digit is normalized, it is simple: 0, 1, 2, 3, 4 -> 0, and 5, 6, 7, 8, 9 -> 1.
When two digits are normalized, two-digit numbers are taken into account: 0 - 49 -> 0, and 50 - 99 -> 1. After all, if the number 1.49 has to be rounded to integers, do we really have to get 2, which is 51 hundredths vs. the available 49 hundredths distance to 1?
It is the same with three-digit, four-digit, etc.
But 1.45 is rounded up to 2, but only if it has previously been normalized to one degree higher precision.
v1 = 0 = 1.0000000, v2 = 0 = 2.0000000
v1 = 1 = 1.5000000, v2 = 1 = 1.5000000
v1 = 2 = 1.4500000, v2 = 2 = 1.4600000
v1 = 3 = 1.4550000, v2 = 3 = 1.4550000
it turns out that if in the calculations of the number was normalized to a higher accuracy and in subsequent calculations to normalize this number to a lower accuracy will result in a different from the simply normalized this number to a lower accuracy.
it turns out that if in the calculation the number was normalised to a higher accuracy and in subsequent calculations the number is normalised to a lower accuracy, the result is different from just normalising the number to a lower accuracy.
Excuse me, but how do you get the values you want?
If I use the recommended functions, then:
- In one case I get correctly rounded value
0.06-0.02 =NormalizeDouble(0.03999999999999999,2) = 0.04
The division is approximated and normalization is required.
- In the second case, I also get rounding, but it is not needed in this case
0.06-0.024 = NormalizeDouble(0.036,2) = 0.04
Normalization (rounding) is not needed here.
But how do I normalize instead of rounding?
Excuse me, but how do you get the values you want?
For that, it's just worth formulating what the "right values" are ))
If I use the recommended functions, then:
- In one case I get a properly rounded value
0.06-0.02 = NormalizeDouble(0.03999999999999999,2) = 0.04
Dividing is approximated and you can't do without normalization.
- In the second case, I also get rounding, but it is not needed in this case
0.06-0.024 = NormalizeDouble(0.036,2) = 0.04
Normalization (rounding) is not required here.
But how do I normalise properly, rather than rounding the values?
The example above shows that you're using some intuitive algorithm that determines the "rightness" of normalization. In the first case, it is an infinite fraction, while in the second case it is a finite one. Adjust your algorithm for converting the real number to the desired form.
Although the easiest way - decide in advance on the required accuracy of calculations.
To do this, it is simply worth formulating what the 'right values' are ))
From the above example, you can see that you are using some intuitive algorithm, by which you determine the "necessity" of normalization. In the first case, it is an infinite fraction, while in the second case it is a finite one. Adjust your algorithm for converting the real number to the desired form.
Although the easiest way is to decide in advance what accuracy you need.
If you want 0.036 (3 decimal places), normalize to 3, not 2.
I was wrong, up to 3 digits should be normalised. Is it possible to do this?
I was wrong, up to 3 digits should be normalised. Will it work that way?
Here's your code:
Instead of 2, put 3 and it's 0.036.