Yes, floating point calculations.

http://docs.sun.com/source/806-3568/ncg_goldberg.html
Bring a pillow. :)


You could do: 

ans1 = 1.3941 - 1.3931;
ans2 = ((1.3941*1000)-(1.3931*1000)) / 1000;
_TRACE("Ans1 = " + ans1);
_TRACE("Ans2 = " + ans2);

though I don't know for sure that there aren't any precision pitfalls with this 
technique.

Jules.

--- In [email protected], "paul_79c" <paul...@...> wrote:
>
> Does anyone know why Amibroker is unable to give the correct answer to this:
> 
> fh = fopen( "C:/Amibroker/"+Name()+"1.txt", "r"); 
> if( fh!=0) 
> {
> k=StrToNum(fgets(fh));
> fclose(fh);
> }
> fh1 = fopen( "C:/Amibroker/"+Name()+"spread.txt", "r"); 
> if( fh1!=0 )
> { 
> k1=Prec(StrToNum(fgets(fh1)),4);
> fclose(fh1);  
> }
> a=Prec(abs((LastValue(C)+k1)-k)+0.0001,4);
> 
> I`m using this code on EURUSD trying to perform a simple subtraction but 
> Amibroker is unable to give a precise answer, like for example sometimes 
> 1.3941-1.3931=0.0009 sometimes =0.0010(correct) sometimes 0.0008 or other 
> close value.  dont get it its a simple subtraction, obviously has something 
> to do with floating point does someone know what to do to get the right 
> answer from amibroker?
>


Reply via email to