public override FormulaValue GetResult(IRContext irContext) { if (_count == 0) { return(CommonErrors.DivByZeroError(irContext)); } return(new NumberValue(irContext, _accumulator / _count)); }
// Average([1,2,3], Value * Value) public static FormulaValue AverageTable(EvalVisitor runner, SymbolContext symbolContext, IRContext irContext, FormulaValue[] args) { var arg0 = (TableValue)args[0]; if (arg0.Rows.Count() == 0) { return(CommonErrors.DivByZeroError(irContext)); } return(RunAggregator(new AverageAgg(), runner, symbolContext, irContext, args)); }
private static FormulaValue DivideByZeroChecker(IRContext irContext, int index, FormulaValue arg) { var finiteCheckResult = FiniteChecker(irContext, index, arg); if (index == 1 && finiteCheckResult is NumberValue numberArg) { var number = numberArg.Value; if (number == 0) { return(CommonErrors.DivByZeroError(irContext)); } } return(arg); }