Commit 22c80a68 authored by GoshaZotov's avatar GoshaZotov

add CEILING.MATH formula

parent ff491ea4
...@@ -810,6 +810,24 @@ $( function () { ...@@ -810,6 +810,24 @@ $( function () {
strictEqual( oParser.calculate().getValue(), -4, 'FLOOR.MATH(-5.5, 2, -1)' ); strictEqual( oParser.calculate().getValue(), -4, 'FLOOR.MATH(-5.5, 2, -1)' );
} ); } );
test( "Test: \"CEILING.MATH\"", 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)' );
oParser = new parserFormula( 'CEILING.MATH(6.7)', "A1", ws );
ok( oParser.parse(), 'CEILING.MATH(6.7)' );
strictEqual( oParser.calculate().getValue(), 7, 'CEILING.MATH(6.7)' );
oParser = new parserFormula( 'CEILING.MATH(-8.1, 2)', "A1", ws );
ok( oParser.parse(), 'CEILING.MATH(-8.1, 2)' );
strictEqual( oParser.calculate().getValue(), -8, 'CEILING.MATH(-8.1, 2)' );
oParser = new parserFormula( 'CEILING.MATH(-5.5, 2, -1)', "A1", ws );
ok( oParser.parse(), 'CEILING.MATH(-5.5, 2, -1)' );
strictEqual( oParser.calculate().getValue(), -6, 'CEILING.MATH(-5.5, 2, -1)' );
} );
test( "Test: \"ARABIC('LVII')\"", function () { test( "Test: \"ARABIC('LVII')\"", function () {
oParser = new parserFormula( 'ARABIC("LVII")', "A1", ws ); oParser = new parserFormula( 'ARABIC("LVII")', "A1", ws );
ok( oParser.parse() ); ok( oParser.parse() );
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
cFormulaFunctionGroup['Financial'] = cFormulaFunctionGroup['Financial'] || []; cFormulaFunctionGroup['Financial'] = cFormulaFunctionGroup['Financial'] || [];
cFormulaFunctionGroup['Financial'].push(cPDURATION, cRRI); cFormulaFunctionGroup['Financial'].push(cPDURATION, cRRI);
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || []; cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
cFormulaFunctionGroup['Mathematic'].push(cAGGREGATE, cBASE, cCEILING_MATH, cCEILING_PRECISE, cFormulaFunctionGroup['Mathematic'].push(cAGGREGATE, cBASE, cCEILING_PRECISE,
cCOMBINA, cDECIMAL, cMUNIT); cCOMBINA, cDECIMAL, cMUNIT);
cFormulaFunctionGroup['LookupAndReference'] = cFormulaFunctionGroup['LookupAndReference'] || []; cFormulaFunctionGroup['LookupAndReference'] = cFormulaFunctionGroup['LookupAndReference'] || [];
cFormulaFunctionGroup['LookupAndReference'].push(cFORMULATEXT); cFormulaFunctionGroup['LookupAndReference'].push(cFORMULATEXT);
...@@ -221,18 +221,6 @@ ...@@ -221,18 +221,6 @@
cBITXOR.prototype = Object.create(cBaseFunction.prototype); cBITXOR.prototype = Object.create(cBaseFunction.prototype);
cBITXOR.prototype.constructor = cBITXOR; cBITXOR.prototype.constructor = cBITXOR;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCEILING_MATH() {
cBaseFunction.call(this, "CEILING.MATH");
this.isXLFN = true;
}
cCEILING_MATH.prototype = Object.create(cBaseFunction.prototype);
cCEILING_MATH.prototype.constructor = cCEILING_MATH;
/** /**
* @constructor * @constructor
* @extends {AscCommonExcel.cBaseFunction} * @extends {AscCommonExcel.cBaseFunction}
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
var _func = AscCommonExcel._func; var _func = AscCommonExcel._func;
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || []; cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
cFormulaFunctionGroup['Mathematic'].push(cABS, cACOS, cACOSH, cACOT, cACOTH, cARABIC, cASIN, cASINH, cATAN, cATAN2, cATANH, cCEILING, cFormulaFunctionGroup['Mathematic'].push(cABS, cACOS, cACOSH, cACOT, cACOTH, cARABIC, cASIN, cASINH, cATAN, cATAN2, cATANH, cCEILING, cCEILING_MATH,
cCOMBIN, cCOS, cCOSH, cCOT, cCOTH, cCSC, cCSCH, cDEGREES, cECMA_CEILING, cEVEN, cEXP, cFACT, cFACTDOUBLE, cFLOOR, cFLOOR_PRECISE, cFLOOR_MATH, cGCD, cINT, 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, 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, cPOWER, cPRODUCT, cQUOTIENT, cRADIANS, cRAND, cRANDBETWEEN, cROMAN, cROUND, cROUNDDOWN, cROUNDUP, cSEC, cSECH, cSERIESSUM,
...@@ -713,6 +713,65 @@ ...@@ -713,6 +713,65 @@
}; };
}; };
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCEILING_MATH() {
this.name = "CEILING.MATH";
this.value = null;
this.argumentsCurrent = 0;
}
cCEILING_MATH.prototype = Object.create(cBaseFunction.prototype);
cCEILING_MATH.prototype.constructor = cCEILING_MATH;
cCEILING_MATH.prototype.argumentsMin = 1;
cCEILING_MATH.prototype.argumentsMax = 3;
cCEILING_MATH.prototype.isXLFN = true;
cCEILING_MATH.prototype.Calculate = function (arg) {
var argClone = [];
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
argClone[2] = this._checkCAreaArg(arg[2], arguments[1]);
argClone[0] = argClone[0].tocNumber();
if(!argClone[1]){
argClone[1] = argClone[0] > 0 ? new cNumber(1) : new cNumber(-1);
}
argClone[2] = argClone[2] ? argClone[2].tocNumber() : new cNumber(0);
var argError;
if(false !== (argError = this._checkErrorArg(argClone))){
return this.value = argError;
}
function floor_math(argArray) {
var number = argArray[0];
var significance = argArray[1];
var mod = argArray[2];
if (significance === 0 || number === 0) {
return new cNumber(0.0);
}
if ( number * significance < 0.0 )
significance = - significance;
if ( mod === 0 && number < 0.0 ){
return new cNumber(Math.floor( number / significance) * significance);
}else{
return new cNumber(Math.ceil( number / significance) * significance);
}
}
return this.value = this._findArrayInNumberArguments(argClone, floor_math);
};
cCEILING_MATH.prototype.getInfo = function () {
return {
name: this.name, args: "( x, significance, mode )"
};
};
/** /**
* @constructor * @constructor
* @extends {AscCommonExcel.cBaseFunction} * @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