[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Unable to perform a simple operation



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "paul_79c" <paulyes@xxx> 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?
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/