Download MetaTrader 5
To add comments, please log in or register
Freelance service: the safe way to order a trading robot. Try it!
bushTrader
68
bushTrader 2014.02.14 04:14 

I have noticed that the result of calculations with normalized double values return insanely lengthy answers since build 574.

An example is: Print("profit/loss=",result); // result gives -16.0000000000049

I know that DoubleToStr can be used to shorten it up, but I wondered if better(shorter) input was the answer.

So, I tried this: double highTCprev=NormalizeDouble(MathRound(High[b+1]*MathPow(10,Digits))/MathPow(10,Digits),Digits);

And this: double highTCprev=MathRound(High[b+1]*MathPow(10,Digits))/MathPow(10,Digits);

And still got a crazy long answer either way. Print( "highTCprev=",DoubleToStr(highTCprev,16)); // highTCprev gives 1.3075000000000001

I can't seem to get a clean number without some junk on the end of it. Hmmm.

Keith Watford
Moderator
8007
Keith Watford 2014.02.14 07:46  
bushTrader:

...........

And still got a crazy long answer either way. Print( "highTCprev=",DoubleToStr(highTCprev,16)); // highTCprev gives 1.3075000000000001

I can't seem to get a clean number without some junk on the end of it. Hmmm.

Why use 16?


DoubleToStr(highTCprev,16)

Why not

DoubleToStr(highTCprev,4)

??

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.02.14 09:38  
bushTrader:

I have noticed that the result of calculations with normalized double values return insanely lengthy answers since build 574.

An example is: Print("profit/loss=",result); // result gives -16.0000000000049

I know that DoubleToStr can be used to shorten it up, but I wondered if better(shorter) input was the answer.

So, I tried this: double highTCprev=NormalizeDouble(MathRound(High[b+1]*MathPow(10,Digits))/MathPow(10,Digits),Digits);

And this: double highTCprev=MathRound(High[b+1]*MathPow(10,Digits))/MathPow(10,Digits);

And still got a crazy long answer either way. Print( "highTCprev=",DoubleToStr(highTCprev,16)); // highTCprev gives 1.3075000000000001

I can't seem to get a clean number without some junk on the end of it. Hmmm.

You need to do some reading and understand how double values work . . . the "junk" yo mention is why this thread exists: Can price != price ?
whroeder1
13644
whroeder1 2014.02.14 13:40  
/
To add comments, please log in or register