Commit a38f07a6 authored by GoshaZotov's avatar GoshaZotov

add CEILING.PRECISE formula

parent 22c80a68
......@@ -810,7 +810,7 @@ $( function () {
strictEqual( oParser.calculate().getValue(), -4, 'FLOOR.MATH(-5.5, 2, -1)' );
} );
test( "Test: \"CEILING.MATH\"", function () {
test( "Test: \"CEILING.PRECISE\"", function () {
oParser = new parserFormula( 'CEILING.MATH(24.3, 5)', "A1", ws );
ok( oParser.parse(), 'CEILING.MATH(24.3, 5)' );
strictEqual( oParser.calculate().getValue(), 25, 'CEILING.MATH(24.3, 5)' );
......@@ -828,6 +828,36 @@ $( function () {
strictEqual( oParser.calculate().getValue(), -6, 'CEILING.MATH(-5.5, 2, -1)' );
} );
test( "Test: \"CEILING.PRECISE\"", function () {
oParser = new parserFormula( 'CEILING.PRECISE(4.3)', "A1", ws );
ok( oParser.parse(), 'CEILING.PRECISE(4.3)' );
strictEqual( oParser.calculate().getValue(), 5, 'CEILING.PRECISE(4.3)' );
oParser = new parserFormula( 'CEILING.PRECISE(-4.3)', "A1", ws );
ok( oParser.parse(), 'CEILING.PRECISE(-4.3)' );
strictEqual( oParser.calculate().getValue(), -4, 'CEILING.PRECISE(-4.3)' );
oParser = new parserFormula( 'CEILING.PRECISE(4.3, 2)', "A1", ws );
ok( oParser.parse(), 'CEILING.PRECISE(4.3, 2)' );
strictEqual( oParser.calculate().getValue(), 6, 'CEILING.PRECISE(4.3, 2)' );
oParser = new parserFormula( 'CEILING.PRECISE(4.3,-2)', "A1", ws );
ok( oParser.parse(), 'CEILING.PRECISE(4.3,-2)' );
strictEqual( oParser.calculate().getValue(), 6, 'CEILING.PRECISE(4.3,-2)' );
oParser = new parserFormula( 'CEILING.PRECISE(-4.3,2)', "A1", ws );
ok( oParser.parse(), 'CEILING.PRECISE(-4.3,2)' );
strictEqual( oParser.calculate().getValue(), -4, 'CEILING.PRECISE(-4.3,2)' );
oParser = new parserFormula( 'CEILING.PRECISE(-4.3,-2)', "A1", ws );
ok( oParser.parse(), 'CEILING.PRECISE(-4.3,-2)' );
strictEqual( oParser.calculate().getValue(), -4, 'CEILING.PRECISE(-4.3,-2)' );
oParser = new parserFormula( 'CEILING.PRECISE(test)', "A1", ws );
ok( oParser.parse(), 'CEILING.PRECISE(test)' );
strictEqual( oParser.calculate().getValue(), "#NAME?", 'CEILING.PRECISE(test)' );
} );
test( "Test: \"ARABIC('LVII')\"", function () {
oParser = new parserFormula( 'ARABIC("LVII")', "A1", ws );
ok( oParser.parse() );
......
......@@ -68,7 +68,7 @@
cFormulaFunctionGroup['Financial'] = cFormulaFunctionGroup['Financial'] || [];
cFormulaFunctionGroup['Financial'].push(cPDURATION, cRRI);
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
cFormulaFunctionGroup['Mathematic'].push(cAGGREGATE, cBASE, cCEILING_PRECISE,
cFormulaFunctionGroup['Mathematic'].push(cAGGREGATE, cBASE,
cCOMBINA, cDECIMAL, cMUNIT);
cFormulaFunctionGroup['LookupAndReference'] = cFormulaFunctionGroup['LookupAndReference'] || [];
cFormulaFunctionGroup['LookupAndReference'].push(cFORMULATEXT);
......@@ -221,18 +221,6 @@
cBITXOR.prototype = Object.create(cBaseFunction.prototype);
cBITXOR.prototype.constructor = cBITXOR;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCEILING_PRECISE() {
cBaseFunction.call(this, "CEILING.PRECISE");
this.isXLFN = true;
}
cCEILING_PRECISE.prototype = Object.create(cBaseFunction.prototype);
cCEILING_PRECISE.prototype.constructor = cCEILING_PRECISE;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
......@@ -56,7 +56,7 @@
var _func = AscCommonExcel._func;
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
cFormulaFunctionGroup['Mathematic'].push(cABS, cACOS, cACOSH, cACOT, cACOTH, cARABIC, cASIN, cASINH, cATAN, cATAN2, cATANH, cCEILING, cCEILING_MATH,
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,
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,
......@@ -772,6 +772,54 @@
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCEILING_PRECISE() {
this.name = "CEILING.PRECISE";
this.value = null;
this.argumentsCurrent = 0;
}
cCEILING_PRECISE.prototype = Object.create(cBaseFunction.prototype);
cCEILING_PRECISE.prototype.constructor = cCEILING_PRECISE;
cCEILING_PRECISE.prototype.argumentsMin = 1;
cCEILING_PRECISE.prototype.argumentsMax = 2;
cCEILING_PRECISE.prototype.isXLFN = true;
cCEILING_PRECISE.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] ? argClone[1].tocNumber() : new cNumber(1);
var argError;
if(false !== (argError = this._checkErrorArg(argClone))){
return this.value = argError;
}
function floorHelper(argArray) {
var number = argArray[0];
var significance = argArray[1];
if (significance === 0 || number === 0) {
return new cNumber(0.0);
}
var absSignificance = Math.abs(significance);
var quotient = number / absSignificance;
return new cNumber(Math.ceil(quotient) * absSignificance);
}
return this.value = this._findArrayInNumberArguments(argClone, floorHelper);
};
cCEILING_PRECISE.prototype.getInfo = function () {
return {
name: this.name, args: "( x, significance )"
};
};
/**
* @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