From 2add86ffd65b67c67399eb19c9e386d391aec06e Mon Sep 17 00:00:00 2001 From: daverayment Date: Sat, 29 Nov 2014 22:58:51 +0000 Subject: [PATCH 1/2] Fix to small negative numbers showing '-0'. Fixes the issue where formatting a small negative number would cause '-0' to be shown when the decimals was set to 0. --- test.html | 1 + wNumb.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test.html b/test.html index 9d24666..902dc25 100644 --- a/test.html +++ b/test.html @@ -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(){ diff --git a/wNumb.js b/wNumb.js index ce0b876..722b629 100644 --- a/wNumb.js +++ b/wNumb.js @@ -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; } From e7cdeee7058fc0cce6dbc688e2b7bafb8e030604 Mon Sep 17 00:00:00 2001 From: daverayment Date: Mon, 1 Dec 2014 09:38:35 +0000 Subject: [PATCH 2/2] Update test.html Spacing --- test.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.html b/test.html index 902dc25..b04eead 100644 --- a/test.html +++ b/test.html @@ -46,7 +46,7 @@ }); equal ( Tester.to ( -50.999845 ), '-51' ); - equal ( Tester.to( -0.0000001 ), '0' ); + equal ( Tester.to ( -0.0000001 ), '0' ); }); test( "Testing mark and thousand with longer strings", function(){