Alberto_jazz:
If you explain why you are trying to do what you asked you may get a better answer. Otherwise, subtract 0.001 before normalizing.
Hi all, could you help me with this problem?
In this case output is 0.05.
I need to obtain 0.04. How can I solve?
Thank you!
Alberto_jazz:
I need to obtain 0.04.
Print(NormalizeDouble(0.09/2,2));In this case output is 0.05.
I need to obtain 0.04.
- since 0.09/2 is 0.045, rounding to 2 decimals gives 0.05
- If you need to truncate try
double TruncateDouble(double v, int d){ double mulip = MathPow(10.0,d), trunc = MathFloor(v * multi) / multp; return(trunc); } ///////////// Print(TruncateDouble(0.09/2,2)); // 0.04
- You should change the title of your post "Round to the low" to "Truncate to the low"
@WHRoeder
double TruncateDouble(double v, int d){ // double mulip = MathPow(10.0,d), // trunc = MathFloor(v * multi) / multp; double mulip = MathPow(10.0,d), trunc = MathFloor(v * mulip) / mulip; return(trunc); }
since I am totally mathematically challenged your quickie was totally what needed. I was doing eg,
int i=0.498553*100; double d=i/100.0; Print(d); //0.49
function is now resident in my tools mqh kit bag!
took liberty to c/mul*/mulip/all
was stumped to begin with as totally out of my depth. was do to *ip,*ti,*tp since this is all .ru to me ;-) but got there in the end.
thank you

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
Hi all, could you help me with this problem?
In this case output is 0.05.
I need to obtain 0.04. How can I solve?
Thank you!