Skip to content

Commit

Permalink
Fix to small negative numbers showing '-0'.
Browse files Browse the repository at this point in the history
Fixes the issue where formatting a small negative number would cause
'-0' to be shown when the decimals was set to 0.
  • Loading branch information
daverayment committed Nov 29, 2014
1 parent cda6930 commit 2add86f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
});

equal ( Tester.to ( -50.999845 ), '-51' );
equal ( Tester.to( -0.0000001 ), '0' );
});

test( "Testing mark and thousand with longer strings", function(){
Expand Down
2 changes: 1 addition & 1 deletion wNumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var

// Rounding away decimals might cause a value of -0
// when using very small ranges. Remove those cases.
if ( decimals && parseFloat(input.toFixed(decimals)) === 0 ) {
if ( decimals !== false && parseFloat(input.toFixed(decimals)) === 0 ) {
input = 0;
}

Expand Down

0 comments on commit 2add86f

Please sign in to comment.