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