Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
680a0497
Commit
680a0497
authored
May 29, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add FLOOR.MATH formula
parent
f7b6fd88
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
180 additions
and
17 deletions
+180
-17
cell/.unit-tests/FormulaTests.js
cell/.unit-tests/FormulaTests.js
+18
-0
cell/model/FormulaObjects/_xlfnFunctions.js
cell/model/FormulaObjects/_xlfnFunctions.js
+1
-13
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+161
-4
No files found.
cell/.unit-tests/FormulaTests.js
View file @
680a0497
...
...
@@ -792,6 +792,24 @@ $( function () {
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#NAME?
"
,
'
FLOOR.PRECISE(test)
'
);
}
);
test
(
"
Test:
\"
FLOOR.MATH
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
FLOOR.MATH(24.3, 5)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
FLOOR.MATH(24.3, 5)
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
20
,
'
FLOOR.MATH(24.3, 5)
'
);
oParser
=
new
parserFormula
(
'
FLOOR.MATH(6.7)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
FLOOR.MATH(6.7)
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
6
,
'
FLOOR.MATH(6.7)
'
);
oParser
=
new
parserFormula
(
'
FLOOR.MATH(-8.1, 5)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
FLOOR.MATH(-8.1, 5)
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
-
10
,
'
FLOOR.MATH(-8.1, 5)
'
);
oParser
=
new
parserFormula
(
'
FLOOR.MATH(-5.5, 2, -1)
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
(),
'
FLOOR.MATH(-5.5, 2, -1)
'
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
-
4
,
'
FLOOR.MATH(-5.5, 2, -1)
'
);
}
);
test
(
"
Test:
\"
ARABIC('LVII')
\"
"
,
function
()
{
oParser
=
new
parserFormula
(
'
ARABIC("LVII")
'
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
...
...
cell/model/FormulaObjects/_xlfnFunctions.js
View file @
680a0497
...
...
@@ -69,7 +69,7 @@
cFormulaFunctionGroup
[
'
Financial
'
].
push
(
cPDURATION
,
cRRI
);
cFormulaFunctionGroup
[
'
Mathematic
'
]
=
cFormulaFunctionGroup
[
'
Mathematic
'
]
||
[];
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cAGGREGATE
,
cBASE
,
cCEILING_MATH
,
cCEILING_PRECISE
,
cCOMBINA
,
cDECIMAL
,
c
FLOOR_MATH
,
c
MUNIT
);
cCOMBINA
,
cDECIMAL
,
cMUNIT
);
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
=
cFormulaFunctionGroup
[
'
LookupAndReference
'
]
||
[];
cFormulaFunctionGroup
[
'
LookupAndReference
'
].
push
(
cFORMULATEXT
);
cFormulaFunctionGroup
[
'
Information
'
]
=
cFormulaFunctionGroup
[
'
Information
'
]
||
[];
...
...
@@ -509,18 +509,6 @@
cFILTERXML
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cFILTERXML
.
prototype
.
constructor
=
cFILTERXML
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cFLOOR_MATH
()
{
cBaseFunction
.
call
(
this
,
"
FLOOR.MATH
"
);
this
.
isXLFN
=
true
;
}
cFLOOR_MATH
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cFLOOR_MATH
.
prototype
.
constructor
=
cFLOOR_MATH
;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
...
...
cell/model/FormulaObjects/mathematicFunctions.js
View file @
680a0497
...
...
@@ -57,7 +57,7 @@
cFormulaFunctionGroup
[
'
Mathematic
'
]
=
cFormulaFunctionGroup
[
'
Mathematic
'
]
||
[];
cFormulaFunctionGroup
[
'
Mathematic
'
].
push
(
cABS
,
cACOS
,
cACOSH
,
cACOT
,
cACOTH
,
cARABIC
,
cASIN
,
cASINH
,
cATAN
,
cATAN2
,
cATANH
,
cCEILING
,
cCOMBIN
,
cCOS
,
cCOSH
,
cCOT
,
cCOTH
,
cCSC
,
cCSCH
,
cDEGREES
,
cECMA_CEILING
,
cEVEN
,
cEXP
,
cFACT
,
cFACTDOUBLE
,
cFLOOR
,
cFLOOR_PRECISE
,
cGCD
,
cINT
,
cCOMBIN
,
cCOS
,
cCOSH
,
cCOT
,
cCOTH
,
cCSC
,
cCSCH
,
cDEGREES
,
cECMA_CEILING
,
cEVEN
,
cEXP
,
cFACT
,
cFACTDOUBLE
,
cFLOOR
,
cFLOOR_PRECISE
,
c
FLOOR_MATH
,
c
GCD
,
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
,
cSIGN
,
cSIN
,
cSINH
,
cSQRT
,
cSQRTPI
,
cSUBTOTAL
,
cSUM
,
cSUMIF
,
cSUMIFS
,
cSUMPRODUCT
,
cSUMSQ
,
cSUMX2MY2
,
cSUMX2PY2
,
...
...
@@ -1564,7 +1564,7 @@
var
a
=
elem
;
var
b
=
arg1
.
getElementRowCol
(
r
,
c
);
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
())
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
())
;
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
...
...
@@ -1575,7 +1575,7 @@
var
a
=
elem
;
var
b
=
arg1
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
())
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
())
;
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
...
...
@@ -1586,7 +1586,7 @@
var
a
=
arg0
;
var
b
=
elem
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
())
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
())
;
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
...
...
@@ -1606,6 +1606,163 @@
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cFLOOR_MATH
()
{
this
.
name
=
"
FLOOR.MATH
"
;
this
.
value
=
null
;
this
.
argumentsCurrent
=
0
;
}
cFLOOR_MATH
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cFLOOR_MATH
.
prototype
.
constructor
=
cFLOOR_MATH
;
cFLOOR_MATH
.
prototype
.
argumentsMin
=
1
;
cFLOOR_MATH
.
prototype
.
argumentsMax
=
3
;
cFLOOR_MATH
.
prototype
.
isXLFN
=
true
;
cFLOOR_MATH
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
];
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArea3D
)
{
arg0
=
arg0
.
cross
(
arguments
[
1
]);
}
if
(
arg1
instanceof
cArea
||
arg1
instanceof
cArea3D
)
{
arg1
=
arg1
.
cross
(
arguments
[
1
]);
}
if
(
arg2
instanceof
cArea
||
arg2
instanceof
cArea3D
)
{
arg2
=
arg2
.
cross
(
arguments
[
1
]);
}
arg0
=
arg
[
0
].
tocNumber
();
if
(
!
arg1
){
arg1
=
arg
[
0
]
>
0
?
new
cNumber
(
1
)
:
new
cNumber
(
-
1
);
}
arg2
=
arg
[
2
]
?
arg
[
2
].
tocNumber
()
:
new
cNumber
(
0
);
if
(
arg0
instanceof
cError
)
{
return
this
.
value
=
arg0
;
}
if
(
arg1
instanceof
cError
)
{
return
this
.
value
=
arg1
;
}
if
(
arg2
instanceof
cError
)
{
return
this
.
value
=
arg2
;
}
function
floorHelper
(
number
,
significance
,
mod
)
{
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
.
ceil
(
number
/
significance
)
*
significance
);
}
else
{
return
new
cNumber
(
Math
.
floor
(
number
/
significance
)
*
significance
);
}
}
if
(
arg0
instanceof
cArray
&&
arg1
instanceof
cArray
&&
arg2
instanceof
cArray
)
{
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
elem
;
var
b
=
arg1
.
getElementRowCol
(
r
,
c
);
var
d
=
arg2
.
getElementRowCol
(
r
,
c
);
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
if
(
arg0
instanceof
cArray
&&
arg1
instanceof
cArray
)
{
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
elem
;
var
b
=
arg1
.
getElementRowCol
(
r
,
c
);
var
d
=
arg2
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
if
(
arg0
instanceof
cArray
&&
arg2
instanceof
cArray
)
{
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
elem
;
var
b
=
arg1
;
var
d
=
arg2
.
getElementRowCol
(
r
,
c
);
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
if
(
arg1
instanceof
cArray
&&
arg2
instanceof
cArray
)
{
arg1
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
arg0
;
var
b
=
elem
;
var
d
=
arg2
.
getElementRowCol
(
r
,
c
);
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg1
;
}
else
if
(
arg0
instanceof
cArray
)
{
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
elem
;
var
b
=
arg1
;
var
d
=
arg2
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
if
(
arg1
instanceof
cArray
)
{
arg1
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
arg0
;
var
b
=
elem
;
var
d
=
arg2
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg1
;
}
else
if
(
arg2
instanceof
cArray
)
{
arg2
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
arg0
;
var
b
=
arg1
;
var
d
=
elem
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg2
;
}
if
(
arg0
instanceof
cString
||
arg1
instanceof
cString
||
arg2
instanceof
cString
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
return
this
.
value
=
floorHelper
(
arg0
.
getValue
(),
arg1
.
getValue
(),
arg2
.
getValue
());
};
cFLOOR_MATH
.
prototype
.
getInfo
=
function
()
{
return
{
name
:
this
.
name
,
args
:
"
( x, significance, mode )
"
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment