Commit 063c3d8f authored by GoshaZotov's avatar GoshaZotov

add COMBINA formula

parent 7b2d67b6
......@@ -884,6 +884,24 @@ $( function () {
strictEqual( oParser.calculate().getValue(), -4, 'ISO.CEILING(-4.3,-2)' );
} );
test( "Test: \"COMBINA\"", function () {
oParser = new parserFormula( 'COMBINA(4,3)', "A1", ws );
ok( oParser.parse(), 'COMBINA(4,3)' );
strictEqual( oParser.calculate().getValue(), 20, 'COMBINA(4,3)' );
oParser = new parserFormula( 'COMBINA(10,3)', "A1", ws );
ok( oParser.parse(), 'COMBINA(10,3)' );
strictEqual( oParser.calculate().getValue(), 220, 'COMBINA(10,3)' );
oParser = new parserFormula( 'COMBINA(3,10)', "A1", ws );
ok( oParser.parse(), 'COMBINA(3,10)' );
strictEqual( oParser.calculate().getValue(), "#NUM!", 'COMBINA(10,3)' );
oParser = new parserFormula( 'COMBINA(10,-3)', "A1", ws );
ok( oParser.parse(), 'COMBINA(10,-3)' );
strictEqual( oParser.calculate().getValue(), "#NUM!", 'COMBINA(10,-3)' );
} );
test( "Test: \"ARABIC('LVII')\"", function () {
oParser = new parserFormula( 'ARABIC("LVII")', "A1", ws );
ok( oParser.parse() );
......
......@@ -68,8 +68,7 @@
cFormulaFunctionGroup['Financial'] = cFormulaFunctionGroup['Financial'] || [];
cFormulaFunctionGroup['Financial'].push(cPDURATION, cRRI);
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
cFormulaFunctionGroup['Mathematic'].push(cAGGREGATE, cBASE,
cCOMBINA, cDECIMAL, cMUNIT);
cFormulaFunctionGroup['Mathematic'].push(cAGGREGATE, cBASE, cDECIMAL, cMUNIT);
cFormulaFunctionGroup['LookupAndReference'] = cFormulaFunctionGroup['LookupAndReference'] || [];
cFormulaFunctionGroup['LookupAndReference'].push(cFORMULATEXT);
cFormulaFunctionGroup['Information'] = cFormulaFunctionGroup['Information'] || [];
......
......@@ -57,7 +57,7 @@
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
cFormulaFunctionGroup['Mathematic'].push(cABS, cACOS, cACOSH, cACOT, cACOTH, cARABIC, cASIN, cASINH, cATAN, cATAN2, cATANH, cCEILING, cCEILING_MATH, cCEILING_PRECISE,
cCOMBIN, cCOS, cCOSH, cCOT, cCOTH, cCSC, cCSCH, cDEGREES, cECMA_CEILING, cEVEN, cEXP, cFACT, cFACTDOUBLE, cFLOOR, cFLOOR_PRECISE, cFLOOR_MATH, cGCD, cINT,
cCOMBIN, cCOMBINA, cCOS, cCOSH, cCOT, cCOTH, cCSC, cCSCH, cDEGREES, cECMA_CEILING, cEVEN, cEXP, cFACT, cFACTDOUBLE, cFLOOR, cFLOOR_PRECISE, cFLOOR_MATH, cGCD, cINT,
cISO_CEILING, cLCM, cLN, cLOG, cLOG10, cMDETERM, cMINVERSE, cMMULT, cMOD, cMROUND, cMULTINOMIAL, cODD, cPI,
cPOWER, cPRODUCT, cQUOTIENT, cRADIANS, cRAND, cRANDBETWEEN, cROMAN, cROUND, cROUNDDOWN, cROUNDUP, cSEC, cSECH, cSERIESSUM,
cSIGN, cSIN, cSINH, cSQRT, cSQRTPI, cSUBTOTAL, cSUM, cSUMIF, cSUMIFS, cSUMPRODUCT, cSUMSQ, cSUMX2MY2, cSUMX2PY2,
......@@ -911,6 +911,50 @@
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCOMBINA() {
this.name = "COMBINA";
this.value = null;
this.argumentsCurrent = 0;
}
cCOMBINA.prototype = Object.create(cBaseFunction.prototype);
cCOMBINA.prototype.constructor = cCOMBINA;
cCOMBINA.prototype.argumentsMin = 2;
cCOMBINA.prototype.argumentsMax = 2;
cCOMBINA.prototype.isXLFN = true;
cCOMBINA.prototype.Calculate = function (arg) {
var argClone = [];
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1].tocNumber();
function floorHelper(argArray) {
var a = argArray[0];
var b = argArray[1];
if (a < 0 || b < 0 || a < b) {
return new cError(cErrorType.not_numeric);
}
a = parseInt(a);
b = parseInt(b);
return new cNumber(Math.binomCoeff(a + b - 1, b));
}
return this.value = this._findArrayInNumberArguments(argClone, floorHelper);
};
cCOMBINA.prototype.getInfo = function () {
return {
name: this.name, args: "( number , number-chosen )"
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment