Download MetaTrader 5

Help requested on double values since build 574.

To add comments, please log in or register
Publish your trading signal. Gain access to millions of traders!
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
9604
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
17998
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
14477
whroeder1 2014.02.14 13:40  
To add comments, please log in or register