Commit 4f68a25f authored by GoshaZotov's avatar GoshaZotov

add unit-test for FLOOR.PRECISE formula

add changes into formula calculation
parent b5f7a7cf
......@@ -766,7 +766,31 @@ $( function () {
strictEqual( oParser.calculate().getValue(), "#VALUE!", 'SECH("test")' );
} );
test( "Test: \"FLOOR.PRECISE\"", function () {
oParser = new parserFormula( 'FLOOR.PRECISE(-3.2, -1)', "A1", ws );
ok( oParser.parse(), 'FLOOR.PRECISE(-3.2, -1)' );
strictEqual( oParser.calculate().getValue(), -4, 'FLOOR.PRECISE(-3.2, -1)' );
oParser = new parserFormula( 'FLOOR.PRECISE(3.2, 1)', "A1", ws );
ok( oParser.parse(), 'FLOOR.PRECISE(3.2, 1)' );
strictEqual( oParser.calculate().getValue(), 3, 'FLOOR.PRECISE(3.2, 1)' );
oParser = new parserFormula( 'FLOOR.PRECISE(-3.2, 1)', "A1", ws );
ok( oParser.parse(), 'FLOOR.PRECISE(-3.2, 1)' );
strictEqual( oParser.calculate().getValue(), -4, 'FLOOR.PRECISE(-3.2, 1)' );
oParser = new parserFormula( 'FLOOR.PRECISE(3.2, -1)', "A1", ws );
ok( oParser.parse(), 'FLOOR.PRECISE(3.2, -1)' );
strictEqual( oParser.calculate().getValue(), 3, 'FLOOR.PRECISE(3.2, -1)' );
oParser = new parserFormula( 'FLOOR.PRECISE(3.2)', "A1", ws );
ok( oParser.parse(), 'FLOOR.PRECISE(3.2)' );
strictEqual( oParser.calculate().getValue(), 3, 'FLOOR.PRECISE(3.2)' );
oParser = new parserFormula( 'FLOOR.PRECISE(test)', "A1", ws );
ok( oParser.parse(), 'FLOOR.PRECISE(test)' );
strictEqual( oParser.calculate().getValue(), "#NAME?", 'FLOOR.PRECISE(test)' );
} );
test( "Test: \"ARABIC('LVII')\"", function () {
oParser = new parserFormula( 'ARABIC("LVII")', "A1", ws );
......
......@@ -1554,9 +1554,9 @@
return new cNumber(0.0);
}
var sign = number > 0 ? 1 : -1;
var quotient = Math.abs(number / significance);
return new cNumber(sign * Math.floor(quotient) * Math.abs(significance));
var absSignificance = Math.abs(significance);
var quotient = number / absSignificance;
return new cNumber(Math.floor(quotient) * absSignificance);
}
if (arg0 instanceof cArray && arg1 instanceof cArray) {
......
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