Skip to content

Commit be6aeb9

Browse files
arvind-kalyanrxaviers
authored andcommitted
Number: Fix for rounding decimals
- Unit test included. Closes #415 Fixes #379 Ref #190
1 parent 7c79945 commit be6aeb9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/number/format/integer-fraction-digits.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
define([
2-
"../../util/number/truncate",
32
"../../util/string/pad"
4-
], function( numberTruncate, stringPad ) {
3+
], function( stringPad ) {
54

65
/**
76
* integerFractionDigits( number, minimumIntegerDigits, minimumFractionDigits,
@@ -43,7 +42,7 @@ return function( number, minimumIntegerDigits, minimumFractionDigits, maximumFra
4342
number = number.join( "." );
4443
}
4544
} else {
46-
number = numberTruncate( number );
45+
number = round( number );
4746
}
4847

4948
number = String( number );

test/functional/currency/currency-formatter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ QUnit.test( "should return a currency formatter, overriden by Supplemental Curre
104104
assert.equal( Globalize.currencyFormatter( "CLF" )( 12345 ), "CLF 12,345.0000" );
105105
assert.equal( Globalize.currencyFormatter( "CLF" )( 12345.67 ), "CLF 12,345.6700" );
106106
assert.equal( Globalize.currencyFormatter( "ZWD" )( 12345 ), "ZWD 12,345" );
107-
assert.equal( Globalize.currencyFormatter( "ZWD" )( 12345.67 ), "ZWD 12,345" );
108-
assert.equal( Globalize.currencyFormatter( "JPY" )( 12345.67 ), "¥12,345" );
107+
assert.equal( Globalize.currencyFormatter( "ZWD" )( 12345.67 ), "ZWD 12,346" );
108+
assert.equal( Globalize.currencyFormatter( "JPY" )( 12345.67 ), "¥12,346" );
109109

110110
assert.equal( Globalize.currencyFormatter( "CLF", code )( 12345.67 ),
111111
"12,345.6700 CLF" );

test/unit/number/format/integer-fraction-digits.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ QUnit.test( "should zero-pad minimum fraction digits", function( assert ) {
4444

4545
QUnit.test( "should allow rounding", function( assert ) {
4646
assert.equal( formatIntegerFractionDigits( pi, 1, 2, 2, round, 0.10 ), "3.10" );
47+
assert.equal( formatIntegerFractionDigits( 100.7, 1, 0, 0, round, null ), "101" );
4748
});
4849

4950
QUnit.test( "should allow different rounding options", function( assert ) {

0 commit comments

Comments
 (0)