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

Re: [amibroker] Optimization



PureBytes Links

Trading Reference Links


Hello,
 
The floating point arithmetic is sometime 
strange :-)
As you probably know decimal fractions 
could not be represented
accuratelly in the IEEE floating point 
format (only powers of 2
could be represented so 0.5, 0.25,0.125, 
0.0625 ... are always precise).
Unfortuntatelly <FONT face="ArialGreek" 
size=2>0.1 can not be represented 100% accuratelly as
a power of 2. So it is in fact 
0.1000000000000000001 or something like that.
Then iterating this leads to 
0.800000000000000008 which is bigger than 0.8
so it is not included in the 
loop.
 
As integers are always represented 
correctly you may use the following
D1= 0.1 * 
Optimize("D1",5,5,8,1);
 
Alternativelly you can use 
this:
<FONT 
size=2>D1=Optimize("D1",0.5,0.5,0.80001,0.1);
 
Anyway, I will try to implement some improvements 
to workaround this problem
internally in AmiBroker.
 
Best regards,
Tomasz Janeczko
amibroker.com
<BLOCKQUOTE 
>
----- Original Message ----- 
<DIV 
>From: 
Dimitris 
Tsokakis 
To: <A 
href="" 
title=amibroker@xxxxxxxxxxxxxxx>amibroker@xxxxxxxxxxxxxxx 
Sent: Tuesday, November 06, 2001 9:16 
AM
Subject: [amibroker] Optimization

Dear Tomasz,
I noticed that in
<FONT 
size=2>D1=Optimize("D1",0.5,0.5,0.8,0.1);
the result list had 
D1=0.5, 0.6, 0.7
In <FONT 
size=2>D1=Optimize("D1",0.5,0.5,0.6,0.01);
the result was complete
D1=0.5, 0.51, 0.52, ..., 0.59, 0.60
Is there any reason for the first case?
Best Regards
Dimitris TsokakisYour use of Yahoo! 
Groups is subject to the Yahoo! 
Terms of Service.