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

Re[2]: Language problems causes bugs not to be understood as the bug sthey are



PureBytes Links

Trading Reference Links

This works:

Value1 = 0.107;
Value2 = 0.107;
If Value1 = Value2 Then Value1 = 0;
plot1 (Value1);

So does this:

Value1 = 10.487 - 10.380;
Value2 = 10.380 - 10.273;
If Value1 = Value2 Then Value1 = 0;
plot1 (Value1);

(I added 0.1 to all values)

It also works if you add 0.01 to all the values.

It doesn't work, however, if you add or subtract 0.001 from all the values.

interesting



At 07:47 PM 7/16/2001 -0700, ztrader wrote:
>On Monday, July 16, 2001, 4:15:11 PM, Bengtsson, Mats wrote:
>
>BM> ******************************************
>BM> {Test Indicator, must plot Zero line}
>BM> Value1 = 10.387 - 10.280;
>BM> Value2 = 10.280 - 10.173;
>BM> If Value1 = Value2 Then Value1 = 0;
>BM> plot1 (Value1);
>BM> ******************************************
>
>TS has trouble when two decimal values are compared (Val1 = Val2).
>They are never truly equal if they are calculated from other numbers.
>There are small errors from the precision of the computation. A
>preferred approach is to allow a small error in the comparison:
>
>Value3 = .000001 for example, then use:
>if AbsValue (Value1 - Value2) < Value3 Then Value1 = 0;
>
>This allows numbers to be "equal" within some error that will always
>be there.
>
>HTH,
>
>ztrader