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
What bothers me is that when I calculate a fractional number, normalise it, write it into a variable, then read and normalise it again, I get tails
e.g.
basis[0]=NormalizeDouble(sum_A,2);
GlobalVariableSet("Equity-"+portfolio_id,basis[0]);
...
current=NormalizeDouble(GlobalVariableGet("Equity-"+portfolio_id),2);
text = "Positions synchronized at " + current + " for portfolio: " + portfolio_name;
if(!automatic) MessageBox(text,""); else Print(text);
Now I've changed it to
text = "Positions synchronized at " + DoubleToStr(current,2) + " for portfolio: " + portfolio_name;
if(!automatic) MessageBox(text,""); else Print(text);
and there do not seem to be any tails, whew, whew, whew...
I've already written, I'll repeat - some numbers don't exist in binary. There is no 0.1, no 0.3 and many others. No matter how many times you write double val = NormalizeDouble(0.1434, 1), you will never get 0.1 just because there is no such a number.
For example, numbers are represented as follows:
0.1 = 0.100000000000000000001
0.2 = 0.20000000000000001
0.3 = 0.29999999999999999999999
0.4 = 0.4000000000000000002
0.6 = 0.5999999999999999998
but
0.125 = 0.125
0.25 = 0.25
0.5 = 0.5
If this is very disturbing, you either need to round or write your own bicycle to represent fractional numbers (there may be some libraries, not interested) which won't use fpu.
And no tails are added during conversion to string, they are there initially.
so I've solved my question, we can close the subject
solution: you have to force rounding, even after normalisation
quite possibly... but in terms of the end result - there are tails!
...
There are no tails after normalize.
I think you are misleading the man. What do you mean there are no tails after normalization? There can be no tails only in the string that we got from a number and rounded the value (rounded already in the string, not in double). But there are tails after NormalizeDouble().
Wrong solution. When rounding, you have to multiply, round, divide. After the last division the number will be non-normalized.
What do you mean by normalisation? Stringo was saying here that the algorithm is something like this:
I think you are misleading the man. What do you mean there are no tails after normalization? There can be no tails only in the string that we got from a number and rounded the value (rounded already in the string, not in double). But after NormalizeDouble() there are tails.
What do you mean by normalisation? Stringo was saying here that the algorithm is something like this:
I'm asking you a specific question and you're pouring water on me. How is it normal to explain and argue your point of view?
Read the textbooks and documentation aloud or what? Or read the dictionary aloud, about the word "approximately"?