Commit 7956149a authored by GoshaZotov's avatar GoshaZotov

add ERF.PRECISE formula + modify ERF formula

parent 68e6ec7b
......@@ -7165,6 +7165,26 @@ $( function () {
});
test( "Test: \"ERF.PRECISE\"", function () {
oParser = new parserFormula( "ERF.PRECISE(1)", "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue().toFixed(14)-0, 0.8427007929497149.toFixed(14)-0 );
oParser = new parserFormula( "ERF.PRECISE(1.234)", "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue().toFixed(14)-0, 0.9190394169576684.toFixed(14)-0 );
oParser = new parserFormula( "ERF.PRECISE(0.745)", "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue().toFixed(8) - 0, 0.70792892 );
oParser = new parserFormula( "ERF.PRECISE(1)", "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue().toFixed(8) - 0, 0.84270079 );
});
test( "Test: \"ERFC\"", function () {
oParser = new parserFormula( "ERFC(1.234)", "A2", ws );
......
......@@ -51,7 +51,7 @@
cFormulaFunctionGroup['DateAndTime'] = cFormulaFunctionGroup['DateAndTime'] || [];
cFormulaFunctionGroup['DateAndTime'].push(cDAYS, cISOWEEKNUM);
cFormulaFunctionGroup['Engineering'] = cFormulaFunctionGroup['Engineering'] || [];
cFormulaFunctionGroup['Engineering'].push(cBITAND, cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR, cERF_PRECISE);
cFormulaFunctionGroup['Engineering'].push(cBITAND, cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR);
cFormulaFunctionGroup['TextAndData'] = cFormulaFunctionGroup['TextAndData'] || [];
cFormulaFunctionGroup['TextAndData'].push(cDBCS, cUNICHAR, cUNICODE);
cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || [];
......@@ -71,7 +71,7 @@
cFormulaFunctionGroup['NotRealised'] = cFormulaFunctionGroup['NotRealised'] || [];
cFormulaFunctionGroup['NotRealised'].push(cDAYS, cISOWEEKNUM, cBITAND, cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR,
cERF_PRECISE, cDBCS, cUNICHAR, cUNICODE, cBINOM_DIST_RANGE, cCHISQ_TEST,
cDBCS, cUNICHAR, cUNICODE, cBINOM_DIST_RANGE, cCHISQ_TEST,
cCOVARIANCE_P, cCOVARIANCE_S, cF_TEST, cFORECAST_ETS, cFORECAST_ETS_CONFINT, cFORECAST_ETS_SEASONALITY,
cFORECAST_ETS_STAT, cHYPGEOM_DIST, cNEGBINOM_DIST, cNORM_DIST,
cNORM_INV, cNORM_S_DIST, cNORM_S_INV, cPERMUTATIONA, cPHI,
......@@ -234,18 +234,6 @@
cDBCS.prototype = Object.create(cBaseFunction.prototype);
cDBCS.prototype.constructor = cDBCS;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cERF_PRECISE() {
cBaseFunction.call(this, "ERF.PRECISE");
this.isXLFN = true;
}
cERF_PRECISE.prototype = Object.create(cBaseFunction.prototype);
cERF_PRECISE.prototype.constructor = cERF_PRECISE;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
......@@ -936,7 +936,7 @@
cFormulaFunctionGroup['Engineering'] = cFormulaFunctionGroup['Engineering'] || [];
cFormulaFunctionGroup['Engineering'].push(cBESSELI, cBESSELJ, cBESSELK, cBESSELY, cBIN2DEC, cBIN2HEX, cBIN2OCT,
cCOMPLEX, cCONVERT, cDEC2BIN, cDEC2HEX, cDEC2OCT, cDELTA, cERF, cERFC, cERFC_PRECISE, cGESTEP, cHEX2BIN,
cCOMPLEX, cCONVERT, cDEC2BIN, cDEC2HEX, cDEC2OCT, cDELTA, cERF, cERF_PRECISE, cERFC, cERFC_PRECISE, cGESTEP, cHEX2BIN,
cHEX2DEC, cHEX2OCT, cIMABS, cIMAGINARY, cIMARGUMENT, cIMCONJUGATE, cIMCOS, cIMCOSH, cIMCOT, cIMCSC, cIMCSCH,
cIMDIV, cIMEXP, cIMLN, cIMLOG10, cIMLOG2, cIMPOWER, cIMPRODUCT, cIMREAL, cIMSEC, cIMSECH, cIMSIN, cIMSINH,
cIMSQRT, cIMSUB, cIMSUM, cIMTAN, cOCT2BIN, cOCT2DEC, cOCT2HEX);
......@@ -1521,42 +1521,65 @@
cERF.prototype.argumentsMax = 2;
cERF.prototype.Calculate = function (arg) {
var a = arg[0], b = arg[1] ? arg[1] : new cUndefined();
if (a instanceof cArea || a instanceof cArea3D) {
a = a.cross(arguments[1]);
} else if (a instanceof cArray) {
a = a.getElement(0);
}
var oArguments = this._prepareArguments(arg, arguments[1], true);
var argClone = oArguments.args;
if (b instanceof cArea || b instanceof cArea3D) {
b = b.cross(arguments[1]);
} else if (b instanceof cArray) {
b = b.getElement(0);
}
argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1] ? argClone[1].tocNumber() : new cUndefined();
a = a.tocNumber();
if (a instanceof cError) {
return this.value = a;
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
}
a = a.getValue();
var calcErf = function(argArray) {
var a = argArray[0];
var b = argArray[1];
if (!( b instanceof cUndefined )) {
b = b.tocNumber();
if (b instanceof cError) {
return this.value = b
var res;
if(undefined !== b){
res = new cNumber(rtl_math_erf(b) - rtl_math_erf(a));
}else{
res = new cNumber(rtl_math_erf(a));
}
b = b.getValue();
return res;
};
return this.value = this._findArrayInNumberArguments(oArguments, calcErf);
};
this.value = new cNumber(rtl_math_erf(b) - rtl_math_erf(a));
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cERF_PRECISE() {
cBaseFunction.call(this, "ERF.PRECISE");
}
} else {
this.value = new cNumber(rtl_math_erf(a));
cERF_PRECISE.prototype = Object.create(cBaseFunction.prototype);
cERF_PRECISE.prototype.constructor = cERF_PRECISE;
cERF_PRECISE.prototype.argumentsMin = 1;
cERF_PRECISE.prototype.argumentsMax = 1;
cERF_PRECISE.prototype.isXLFN = true;
cERF_PRECISE.prototype.Calculate = function (arg) {
var oArguments = this._prepareArguments(arg, arguments[1], true);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocNumber();
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
}
return this.value;
var calcErf = function(argArray) {
var a = argArray[0];
return new cNumber(rtl_math_erf(a));
};
return this.value = this._findArrayInNumberArguments(oArguments, calcErf);
};
/**
......
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