Commit d763f7db authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

fixed:

Bug 25507 - При сложении ячейки и диапазона ячеек выпадают ошибки в консоли
Bug 25086 - Аргумент Number при вычислении в формуле DEC2BIN/DEC2HEX/DEC2OCT не усекается до целого

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57435 954022d7-b5bf-4e40-9824-e11837661b57
parent 39a21ba5
......@@ -352,36 +352,6 @@ function BesselY( fNum, nOrder ) {
}
}
function erf( x ) {
var sqrtPI2 = 2 / Math.sqrt( Math.PI ), maxIter = 200, eps = 1e-14, res = x * sqrtPI2, v = 1, j = 1, i = 1, oldRes = 0, cont = true,
sqrtPI = Math.sqrt( Math.PI );
/*for ( i = 1; i < maxIter && cont; i++) {
oldRes = res;
for ( j = 1, v = 1; j <= i; j++ ) {
v *= -x * x / j;
}
res += sqrtPI2*x * v / (2 * i + 1);
cont = (Math.abs(oldRes-res) >= eps);
}*/
/* var r = -Math.exp(-x*x)/(x*sqrtPI), mo = -1
x = 2*x*x;
for ( i = 1, res = 1; i < maxIter && cont; i++) {
oldRes = res;
res += Math.pow( -1, i ) * Math.doubleFact( 2*i-1 ) / Math.pow( x, i );
cont = (Math.abs(oldRes-res) >= eps);
}
res = res * r;*/
return res /** sqrtPI2*/;
}
function validBINNumber( n ) {
return rg_validBINNumber.test( n );
}
......@@ -1198,7 +1168,7 @@ cDEC2OCT.prototype.Calculate = function ( arg ) {
arg0 = arg0.tocNumber();
if ( arg0 instanceof cError ) return this.value = new cError( cErrorType.wrong_value_type );
arg0 = arg0.getValue();
arg0 = Math.floor( arg0.getValue() );
if ( !(arg1 instanceof cUndefined) ) {
arg1 = arg1.tocNumber();
......@@ -1279,52 +1249,101 @@ function cERF() {
}
cERF.prototype = Object.create( cBaseFunction.prototype );
/*cERF.prototype.Calculate = function ( arg ) {
cERF.prototype.Calculate = function ( arg ) {
var a = arg[0], b = arg[1] ? arg[1] : new cUndefined();
if ( a instanceof cArea || b instanceof cArea3D ) {
a = a.cross( arguments[1].first );
}
else if ( a instanceof cArray ) {
a = a.getElement(0);
}
var a = arg[0], b = arg[1] ? arg[1] : new cUndefined();
if ( a instanceof cArea || a instanceof cArea3D ) {
a = a.cross( arguments[1].first );
}
else if ( a instanceof cArray ) {
a = a.getElement( 0 );
}
if ( b instanceof cArea || b instanceof cArea3D ) {
b = b.cross( arguments[1].first );
}
else if ( b instanceof cArray ) {
b = b.getElement(0);
}
if ( b instanceof cArea || b instanceof cArea3D ) {
b = b.cross( arguments[1].first );
}
else if ( b instanceof cArray ) {
b = b.getElement( 0 );
}
a = a.tocNumber();
if ( a instanceof cError ){ return this.value = a; }
a = a.tocNumber();
if ( a instanceof cError ) {
return this.value = new cError( cErrorType.wrong_value_type );
}
if( !( b instanceof cUndefined ) ){
b = b.tocNumber();
if ( b instanceof cError ){ return this.value = b; }
a = a.getValue();
this.value = new cNumber( erf( b.getValue() ) - erf( a.getValue() ) );
if ( a < 0 ) {
return this.value = new cError( cErrorType.not_numeric );
}
}
else{
this.value = new cNumber( erf( a.getValue() ) );
}
if ( !( b instanceof cUndefined ) ) {
b = b.tocNumber();
if ( b instanceof cError ) {
return this.value = new cError( cErrorType.wrong_value_type );
}
return this.value;
b = b.getValue();
}
cERF.prototype.getInfo = function () {
return {
name:this.name,
args:"( lower-bound [ , upper-bound ] )"
};
}*/
if ( b < 0 ) {
return this.value = new cError( cErrorType.not_numeric );
}
this.value = new cNumber( rtl_math_erf( b ) - rtl_math_erf( a ) );
}
else {
this.value = new cNumber( rtl_math_erf( a ) );
}
return this.value;
}
cERF.prototype.getInfo = function () {
return {
name:this.name,
args:"( lower-bound [ , upper-bound ] )"
};
}
function cERFC() {
cBaseFunction.call( this, "ERFC" );
cBaseFunction.call( this, "ERFC", 1, 1 );
}
cERFC.prototype = Object.create( cBaseFunction.prototype );
cERFC.prototype.Calculate = function ( arg ) {
var a = arg[0];
if ( a instanceof cArea || a instanceof cArea3D ) {
a = a.cross( arguments[1].first );
}
else if ( a instanceof cArray ) {
a = a.getElement( 0 );
}
a = a.tocNumber();
if ( a instanceof cError ) {
return this.value = new cError( cErrorType.wrong_value_type );
}
a = a.getValue();
if ( a < 0 ) {
this.value = new cError( cErrorType.not_numeric );
}
else {
this.value = new cNumber( rtl_math_erfc( a ) );
}
return this.value;
}
cERFC.prototype.getInfo = function () {
return {
name:this.name,
args:"( lower-bound )"
};
}
function cGESTEP() {
cBaseFunction.call( this, "GESTEP", 1, 2 );
......@@ -2466,4 +2485,4 @@ cOCT2HEX.prototype.getInfo = function () {
name:this.name,
args:"( number [ , num-hex-digits ] )"
};
}
}
\ No newline at end of file
......@@ -119,7 +119,7 @@ cABS.prototype.Calculate = function ( arg ) {
cABS.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
}
}
......@@ -171,7 +171,7 @@ cACOS.prototype.Calculate = function ( arg ) {
cACOS.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -223,7 +223,7 @@ cACOSH.prototype.Calculate = function ( arg ) {
cACOSH.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -275,7 +275,7 @@ cASIN.prototype.Calculate = function ( arg ) {
cASIN.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -327,7 +327,7 @@ cASINH.prototype.Calculate = function ( arg ) {
cASINH.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -380,7 +380,7 @@ cATAN.prototype.Calculate = function ( arg ) {
cATAN.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -526,7 +526,7 @@ cATANH.prototype.Calculate = function ( arg ) {
cATANH.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -634,7 +634,7 @@ cCEILING.prototype.Calculate = function ( arg ) {
cCEILING.prototype.getInfo = function () {
return {
name:this.name,
args:"(number, significance)"
args:"( x, significance )"
};
}
......@@ -783,7 +783,7 @@ cCOS.prototype.Calculate = function ( arg ) {
cCOS.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -835,7 +835,7 @@ cCOSH.prototype.Calculate = function ( arg ) {
cCOSH.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -888,7 +888,7 @@ cDEGREES.prototype.Calculate = function ( arg ) {
cDEGREES.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( angle )"
};
}
......@@ -967,7 +967,7 @@ cEVEN.prototype.Calculate = function ( arg ) {
cEVEN.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -1022,7 +1022,7 @@ cEXP.prototype.Calculate = function ( arg ) {
cEXP.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -1079,7 +1079,7 @@ cFACT.prototype.Calculate = function ( arg ) {
cFACT.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -1150,7 +1150,7 @@ cFACTDOUBLE.prototype.Calculate = function ( arg ) {
cFACTDOUBLE.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -1257,7 +1257,7 @@ cFLOOR.prototype.Calculate = function ( arg ) {
cFLOOR.prototype.getInfo = function () {
return {
name:this.name,
args:"(number, significance)"
args:"( x, significance )"
};
}
......@@ -1413,7 +1413,7 @@ cINT.prototype.Calculate = function ( arg ) {
cINT.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -1584,7 +1584,7 @@ cLN.prototype.Calculate = function ( arg ) {
cLN.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -1684,7 +1684,7 @@ cLOG.prototype.Calculate = function ( arg ) {
cLOG.prototype.getInfo = function () {
return {
name:this.name,
args:"(number [ , base ])"
args:"( x [ , base ] )"
};
}
......@@ -1741,7 +1741,7 @@ cLOG10.prototype.Calculate = function ( arg ) {
cLOG10.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -2148,7 +2148,7 @@ cMOD.prototype.Calculate = function ( arg ) {
cMOD.prototype.getInfo = function () {
return {
name:this.name,
args:"(number, divisor)"
args:"( x, y )"
};
}
......@@ -2259,7 +2259,7 @@ cMROUND.prototype.Calculate = function ( arg ) {
cMROUND.prototype.getInfo = function () {
return {
name:this.name,
args:"(number, multiple)"
args:"( x, multiple )"
};
}
......@@ -2437,7 +2437,7 @@ cODD.prototype.Calculate = function ( arg ) {
cODD.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -2547,7 +2547,7 @@ cPOWER.prototype.Calculate = function ( arg ) {
return this.value = arg1;
}
if ( !(arg0 instanceof cNumber) || ( arg1 && !(arg0 instanceof cNumber) ) ){
if ( !(arg0 instanceof cNumber) || ( arg1 && !(arg0 instanceof cNumber) ) ) {
return this.value = new cError( cErrorType.wrong_value_type );
}
......@@ -2557,7 +2557,7 @@ cPOWER.prototype.Calculate = function ( arg ) {
cPOWER.prototype.getInfo = function () {
return {
name:this.name,
args:"(number, power)"
args:"( x, y )"
};
}
......@@ -2617,7 +2617,7 @@ cPRODUCT.prototype.Calculate = function ( arg ) {
cPRODUCT.prototype.getInfo = function () {
return {
name:this.name,
args:"( number1, number2, ... )"
args:"( argument-list )"
};
}
......@@ -2760,7 +2760,7 @@ cRADIANS.prototype.Calculate = function ( arg ) {
cRADIANS.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( angle )"
};
}
......@@ -3151,7 +3151,7 @@ cROUND.prototype.Calculate = function ( arg ) {
cROUND.prototype.getInfo = function () {
return {
name:this.name,
args:"(number, num_digits)"
args:"( x , number-digits )"
};
}
......@@ -3276,7 +3276,7 @@ cROUNDDOWN.prototype.Calculate = function ( arg ) {
cROUNDDOWN.prototype.getInfo = function () {
return {
name:this.name,
args:"(number, num_digits)"
args:"( x , number-digits )"
};
}
......@@ -3401,7 +3401,7 @@ cROUNDUP.prototype.Calculate = function ( arg ) {
cROUNDUP.prototype.getInfo = function () {
return {
name:this.name,
args:"(number, num_digits)"
args:"( x , number-digits )"
};
}
......@@ -3548,7 +3548,7 @@ cSIGN.prototype.Calculate = function ( arg ) {
cSIGN.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -3598,7 +3598,10 @@ cSIN.prototype.Calculate = function ( arg ) {
return this.value = arg0;
}
cSIN.prototype.getInfo = function () {
return { name:this.name, args:"(number)" }
return {
name:this.name,
args:"( x )"
};
}
function cSINH() {
......@@ -3649,7 +3652,7 @@ cSINH.prototype.Calculate = function ( arg ) {
cSINH.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -3701,7 +3704,7 @@ cSQRT.prototype.Calculate = function ( arg ) {
cSQRT.prototype.getInfo = function () {
return {
name:this.name,
args:"( number )"
args:"( x )"
};
}
......@@ -3753,7 +3756,7 @@ cSQRTPI.prototype.Calculate = function ( arg ) {
cSQRTPI.prototype.getInfo = function () {
return {
name:this.name,
args:"( number )"
args:"( x )"
};
}
......@@ -3822,7 +3825,7 @@ cSUM.prototype.Calculate = function ( arg ) {
cSUM.prototype.getInfo = function () {
return {
name:this.name,
args:"(number1, number2, ...)"
args:"( argument-list )"
};
}
......@@ -4002,7 +4005,7 @@ cSUMPRODUCT.prototype.Calculate = function ( arg ) {
cSUMPRODUCT.prototype.getInfo = function () {
return {
name:this.name,
args:"( argument-lists )"
args:"( argument-list )"
};
}
......@@ -4417,7 +4420,7 @@ cTAN.prototype.Calculate = function ( arg ) {
cTAN.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -4469,7 +4472,7 @@ cTANH.prototype.Calculate = function ( arg ) {
cTANH.prototype.getInfo = function () {
return {
name:this.name,
args:"(number)"
args:"( x )"
};
}
......@@ -4581,5 +4584,4 @@ cTRUNC.prototype.getInfo = function () {
name:this.name,
args:"( x [ , number-digits ] )"
};
}
}
\ No newline at end of file
......@@ -585,7 +585,14 @@ cArea.prototype.getRange = function () {
return this.range;
};
cArea.prototype.tocNumber = function () {
return this.getValue()[0].tocNumber();
var v = this.getValue()[0];
if (!v){
v = new cNumber(0);
}
else{
v = v.tocNumber();
}
return v;
};
cArea.prototype.tocString = function () {
return this.getValue()[0].tocString();
......@@ -1804,7 +1811,15 @@ function cAddOperator() {
cAddOperator.prototype = Object.create( cBaseOperator.prototype );
cAddOperator.prototype.Calculate = function ( arg ) {
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0].tocNumber(), arg1 = arg[1].tocNumber();
// var arg0 = arg[0].tocNumber(), arg1 = arg[1].tocNumber();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tocNumber(), arg1 = arg1.tocNumber();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "+", arguments[1].first );
};
......@@ -1814,7 +1829,15 @@ function cMinusOperator() {
cMinusOperator.prototype = Object.create( cBaseOperator.prototype );
cMinusOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tocNumber(), arg1 = arg1.tocNumber();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "-", arguments[1].first );
};
......@@ -1888,7 +1911,15 @@ function cMultOperator() {
cMultOperator.prototype = Object.create( cBaseOperator.prototype );
cMultOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tocNumber(), arg1 = arg1.tocNumber();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "*", arguments[1].first );
};
......@@ -1898,7 +1929,15 @@ function cDivOperator() {
cDivOperator.prototype = Object.create( cBaseOperator.prototype );
cDivOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tocNumber(), arg1 = arg1.tocNumber();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "/", arguments[1].first );
};
......@@ -1929,7 +1968,15 @@ function cEqualsOperator() {
cEqualsOperator.prototype = Object.create( cBaseOperator.prototype );
cEqualsOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tryConvert(), arg1 = arg1.tryConvert();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "=", arguments[1].first );
};
......@@ -1939,7 +1986,15 @@ function cNotEqualsOperator() {
cNotEqualsOperator.prototype = Object.create( cBaseOperator.prototype );
cNotEqualsOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tryConvert(), arg1 = arg1.tryConvert();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "<>", arguments[1].first );
};
......@@ -1949,7 +2004,15 @@ function cLessOperator() {
cLessOperator.prototype = Object.create( cBaseOperator.prototype );
cLessOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tryConvert(), arg1 = arg1.tryConvert();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "<", arguments[1].first );
};
......@@ -1959,7 +2022,15 @@ function cLessOrEqualOperator() {
cLessOrEqualOperator.prototype = Object.create( cBaseOperator.prototype );
cLessOrEqualOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tryConvert(), arg1 = arg1.tryConvert();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "<=", arguments[1].first );
};
......@@ -1969,7 +2040,15 @@ function cGreaterOperator() {
cGreaterOperator.prototype = Object.create( cBaseOperator.prototype );
cGreaterOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tryConvert(), arg1 = arg1.tryConvert();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, ">", arguments[1].first );
};
......@@ -1979,7 +2058,15 @@ function cGreaterOrEqualOperator() {
cGreaterOrEqualOperator.prototype = Object.create( cBaseOperator.prototype );
cGreaterOrEqualOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
// var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0], arg1 = arg[1];
if ( arg0 instanceof cArea ) {
arg0 = arg0.cross( arguments[1].first );
}
if ( arg1 instanceof cArea ) {
arg1 = arg1.cross( arguments[1].first );
}
arg0 = arg0.tryConvert(), arg1 = arg1.tryConvert();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, ">=", arguments[1].first );
};
......
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