/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { MathUtilities } from "./MathUtilities";
import { markType } from "igniteui-angular-core";
/**
 * @hidden
 */
export class UltraCalcFunctionFloorMath extends BuiltInFunctionBase {
    evaluate(a, b) {
        let c = null;
        let d = null;
        if (b == 3) {
            c = a.pop();
        }
        if (b >= 2) {
            d = a.pop();
        }
        let e = a.pop();
        if (e.isError) {
            return new ExcelCalcValue(e.toErrorValue());
        }
        if (d != null && d.isError) {
            return new ExcelCalcValue(d.toErrorValue());
        }
        if (c != null && c.isError) {
            return new ExcelCalcValue(c.toErrorValue());
        }
        let f = e._toDouble3();
        let g = d == null ? 1 : Math.abs(d._toDouble3());
        let h = c == null ? 0 : c._toDouble3();
        if (f == 0 || g == 0) {
            return new ExcelCalcValue(0);
        }
        let i = f / g;
        if (f < 0 && h != 0) {
            i = Math.ceil(i);
        }
        else {
            i = Math.floor(i);
        }
        return new ExcelCalcValue(MathUtilities.i(i * g));
    }
    get_name() {
        return "floor.math";
    }
    get name() {
        return this.get_name();
    }
    get_minArgs() {
        return 1;
    }
    get minArgs() {
        return this.get_minArgs();
    }
    get_maxArgs() {
        return 3;
    }
    get maxArgs() {
        return this.get_maxArgs();
    }
}
UltraCalcFunctionFloorMath.$t = markType(UltraCalcFunctionFloorMath, 'UltraCalcFunctionFloorMath', BuiltInFunctionBase.$);
//# sourceMappingURL=UltraCalcFunctionFloorMath.js.map