Thank you Tomasz, now ot working properly i did not think of using writeval function. Now im very courious whats the use of PREC function...very confusing... but maybe i did not read the manual carefully..actually i know i did not Thanks anyway now its working perfectly.
--- In [email protected], "Tomasz Janeczko" <gro...@...> wrote: > > Your code is wrong. > Use WriteVal to output numbers with desired number of decimal places or > StrFormat. > > WriveVal( your_variable, 1.4 ); // output with 4 decimal digits > > Best regards, > Tomasz Janeczko > amibroker.com > ----- Original Message ----- > From: "paul_79c" <paul...@...> > To: <[email protected]> > Sent: Tuesday, July 14, 2009 5:42 PM > Subject: [amibroker] Unable to perform a simple operation > > > > 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 > > > > > > >
