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

Built-in Function Error



PureBytes Links

Trading Reference Links

Below is the code from the COMBINATION function.  Note that the code
incorrectly uses the TCNum at locations where TLen should be used.  For
instance, the expression Condition2 = TCNum > TCNum; can never be true.

Inputs: Length(Numeric), CNum(Numeric);
Variables: TLen(0), TCNum(0), FactorN(1), FactorK(1), FactorNK(1);

TLen = IntPortion(Length);
TCNum = IntPortion(CNum);
Condition1 = TCNum > 0 AND TCNum > 0;
Condition2 = TCNum > TCNum;
FactorN = 1;
FactorK = 1;
FactorNK = 1;

If Condition1 AND Condition2 Then Begin
	FactorN = Factorial(TCNum);
	FactorK = Factorial(TCNum);
	FactorNK = Factorial(TCNum-TCNum);

	If FactorK * FactorNK <> 0 Then
		Combination = FactorN / (FactorK * FactorNK)
	Else
		Combination = -1;
End
Else
	Combination = -1;


William Brower
Publisher of TS Express 
Email: 1000mileman@xxxxxxxxxxxxxx
Web: http://www.insideedgesystems.com