/*
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 { __extends } from "tslib";
import { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { markType } from "igniteui-angular-core";
import { isInfinity, isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionMRound = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(UltraCalcFunctionMRound, _super);
    function UltraCalcFunctionMRound() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionMRound.prototype.evaluate = function (a, b) {
        var c = a.pop();
        if (c.isError) {
            return new ExcelCalcValue(c.toErrorValue());
        }
        var d = c._toDouble3();
        var e = a.pop();
        if (e.isError) {
            return new ExcelCalcValue(e.toErrorValue());
        }
        var f = e._toDouble3();
        if (f < 0 && d > 0 || f > 0 && d < 0) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        var g = UltraCalcFunctionMRound._ak(f, d);
        return new ExcelCalcValue(g);
    };
    UltraCalcFunctionMRound.prototype.get_name = function () {
        return "mround";
    };
    Object.defineProperty(UltraCalcFunctionMRound.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionMRound.prototype.get_minArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionMRound.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionMRound.prototype.get_maxArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionMRound.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionMRound._ak = function (a, b) {
        var c = a / b;
        if (isInfinity(c) || isNaN_(c)) {
            return 0;
        }
        c += 0.5;
        c = Math.floor(c);
        return c * b;
    };
    UltraCalcFunctionMRound.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return (b == false);
    };
    UltraCalcFunctionMRound.$t = markType(UltraCalcFunctionMRound, 'UltraCalcFunctionMRound', BuiltInFunctionBase.$);
    return UltraCalcFunctionMRound;
}(BuiltInFunctionBase));
export { UltraCalcFunctionMRound };
