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

Bug report & fix for Average_a function



PureBytes Links

Trading Reference Links

 OLD VERSION :

{***********************************************************************
Description : This Function returns the Average of an Array of values.
Provided By : Omega Research, Inc. (c) Copyright 1999
************************************************************************}

Inputs: AvgArray[size](NumericArrayRef), Array_Size(Numeric);
Variables: Sum(0), Counter(0);
{Array_Size is passed as an Input so that only the array elements that have
been used are referenced}

Sum = 0;
Counter = 0;

For value1 = 1 To Array_Size Begin  {<--** ERROR Value1=0 NOT Value1=1,**
ERROR Array_Size-1 NOT Array_Size  }
 Sum = Sum + AvgArray[value1];
 Counter = Counter + 1;
End;

If Counter <> 0 Then
 Average_a = Sum / Counter
Else
 Average_a = -1;



DEBUGGED VERSION:

***********************************************************************
Description : This Function returns the Average of an Array of values.
Provided By : Omega Research, Inc. (c) Copyright 1999
************************************************************************}

Inputs: AvgArray[size](NumericArrayRef), Array_Size(Numeric);
Variables: Sum(0), Counter(0);
{Array_Size is passed as an Input so that only the array elements that have
been used are referenced}

Sum = 0;
Counter = 0;

For value1 = 0 To Array_Size-1 Begin
 Sum = Sum + AvgArray[value1];
 Counter = Counter + 1;
End;

If Counter <> 0 Then
 Average_a = Sum / Counter
Else
 Average_a = -1;

 
***********************
Claudio Berselli