Skip to content

Commit

Permalink
Fix make function work with negative numbers too
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Jan 12, 2019
1 parent 83c8a93 commit 66c48c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions justgage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,13 +1085,14 @@ function cutHex(str) {

/** Human friendly number suffix - @robertsLando */
function humanFriendlyNumber(n, d) {
var d2, i, s;
var d2, i, s, c;

d2 = Math.pow(10, d);
s = " KMGTPE";
i = 0;
c = 1000;

while(n >= 1000 && ++i < s.length) n = n / 1000;
while((n >= c || n <= -c) && ++i < s.length) n = n / c;

i = i >= s.length ? s.length - 1 : i;

Expand Down

0 comments on commit 66c48c5

Please sign in to comment.