# Help requested on double values since build 574.

68
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.

Moderator
9639
2014.02.14 07:46

...........

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)

??

Moderator
18002
2014.02.14 09:38

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 ?
14739
2014.02.14 13:40