0.02*4.9=0.098 -- not 0.98
output in 2 decimal place format -- 0.098 will be output rounded to 0.10 according to rounding rules
If the output is in 3-digit format -- the whole number will be printed.
Thanks, I corrected the numbers.
That's the problem, you have to take 2 digits after the decimal point. :) Why is it rounded? How can you take a fractional number without rounding and only 2 digits after the decimal point (0.09)?
Thank you, corrected the figures.
That's the problem, you have to take two decimal places. :) Why is it rounded? How can you take a fractional number without rounding and only 2 digits after the decimal point (0.09)?
Thank you, corrected the figures.
That's the problem, you have to take two decimal places. :) Why is it rounded? How can you take a fractional number without rounding and only 2 digits after the decimal point (0.09)?
int a=int(0.098/0.01); double b=a*0.01; Comment(DoubleToString(b,2));
translate it into a string and take the number of characters you want
Do you know any easier way
And if you do:
int a=int((0.09*5)/0.01); double b=a*0.01; Comment (DoubleToString (b,2));
The output is 0.44 instead of the required 0.45.
And if you do:
The output is 0.44 instead of the required 0.45.
int a=int(MathFloor((0.98)/0.001)); double b=a*0.001; Comment(DoubleToString(b,2));
0.098, not 0.98. :)
int a = int (MathFloor ((0.098) / 0.001)); double b = a * 0.001; Comment (DoubleToString (b, 2));
Returns 1, and wanted exact value = 0.09.
Do you know an easier way?
that's the first thing that popped into my head, of course there are simpler ones.
It's not complicated either, but maybe it's slower:
int DIGITS=2; string stroka=DoubleToString(0.09845,8); int P=StringFind(stroka,"."); Print(stroka); stroka=StringSubstr(stroka,0,P+DIGITS+1); Print(StringToDouble(stroka)); возвращает: 2014.10.04 11:32:53.731 normalize EURUSD,H4: 0.09 2014.10.04 11:32:53.731 normalize EURUSD,H4: 0.09845000
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Greetings. I need help with a problem:
All functions return 0.1. Although (0.02*4.9) = 0.098 and should return 0.09.
Please tell me how to get the exact value which returns my calculator? :)