Commit c148f0fe authored by GoshaZotov's avatar GoshaZotov

add BITAND formula

parent a5ae8f75
......@@ -7668,6 +7668,18 @@ $( function () {
});
test( "Test: \"BITAND\"", function () {
oParser = new parserFormula( 'BITAND(1,5)', "AA2", ws );
ok( oParser.parse(), 'BITAND(1,5)' );
strictEqual( oParser.calculate().getValue(), 1, 'BITAND(1,5)' );
oParser = new parserFormula( 'BITAND(13,25)', "AA2", ws );
ok( oParser.parse(), 'BITAND(13,25)' );
strictEqual( oParser.calculate().getValue(), 9, 'BITAND(13,25)' );
});
function putDataForDatabase(){
ws.getRange2( "A1" ).setValue( "Tree" );
ws.getRange2( "A2" ).setValue( "Apple" );
......
......@@ -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);
cFormulaFunctionGroup['Engineering'].push(cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR);
cFormulaFunctionGroup['TextAndData'] = cFormulaFunctionGroup['TextAndData'] || [];
cFormulaFunctionGroup['TextAndData'].push(cDBCS, cUNICHAR, cUNICODE);
cFormulaFunctionGroup['Statistical'] = cFormulaFunctionGroup['Statistical'] || [];
......@@ -67,7 +67,7 @@
cFormulaFunctionGroup['Information'].push(cSHEET, cSHEETS);
cFormulaFunctionGroup['NotRealised'] = cFormulaFunctionGroup['NotRealised'] || [];
cFormulaFunctionGroup['NotRealised'].push(cDAYS, cISOWEEKNUM, cBITAND, cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR,
cFormulaFunctionGroup['NotRealised'].push(cDAYS, cISOWEEKNUM, cBITLSHIFT, cBITOR, cBITRSHIFT, cBITXOR,
cDBCS, cUNICHAR, cUNICODE, cBINOM_DIST_RANGE, cF_TEST, cFORECAST_ETS, cFORECAST_ETS_CONFINT,
cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT, cHYPGEOM_DIST, cPDURATION,
cAGGREGATE, cMUNIT, cFORMULATEXT, cSHEET, cSHEETS);
......@@ -96,18 +96,6 @@
cBINOM_DIST_RANGE.prototype = Object.create(cBaseFunction.prototype);
cBINOM_DIST_RANGE.prototype.constructor = cBINOM_DIST_RANGE;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cBITAND() {
cBaseFunction.call(this, "BITAND");
this.isXLFN = true;
}
cBITAND.prototype = Object.create(cBaseFunction.prototype);
cBITAND.prototype.constructor = cBITAND;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
......@@ -935,7 +935,7 @@
};
cFormulaFunctionGroup['Engineering'] = cFormulaFunctionGroup['Engineering'] || [];
cFormulaFunctionGroup['Engineering'].push(cBESSELI, cBESSELJ, cBESSELK, cBESSELY, cBIN2DEC, cBIN2HEX, cBIN2OCT,
cFormulaFunctionGroup['Engineering'].push(cBESSELI, cBESSELJ, cBESSELK, cBESSELY, cBIN2DEC, cBIN2HEX, cBIN2OCT, cBITAND,
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,
......@@ -1210,6 +1210,46 @@
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cBITAND() {
cBaseFunction.call(this, "BITAND");
}
cBITAND.prototype = Object.create(cBaseFunction.prototype);
cBITAND.prototype.constructor = cBITAND;
cBITAND.prototype.argumentsMin = 2;
cBITAND.prototype.argumentsMax = 2;
cBITAND.prototype.isXLFN = true;
cBITAND.prototype.Calculate = function (arg) {
var oArguments = this._prepareArguments(arg, arguments[1], true);
var argClone = oArguments.args;
argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1].tocNumber();
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
}
var calcFunc = function(argArray){
var arg0 = Math.floor(argArray[0]);
var arg1 = Math.floor(argArray[1]);
if ( arg0 < 0 || arg1 < 0 /*|| arg0 > 2^48 || arg1 > 2^48*/){
return new cError(cErrorType.not_numeric);
}
var res = arg0 & arg1;
return null !== res && !isNaN(res) ? new cNumber(res) : new cError(cErrorType.wrong_value_type);
};
return this.value = this._findArrayInNumberArguments(oArguments, calcFunc);
};
/**
* @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