Skip to content

Commit

Permalink
Round decimal part of numbers to avoid fp arithmic bugs. Fixes #45
Browse files Browse the repository at this point in the history
  • Loading branch information
nervetattoo committed May 18, 2019
1 parent cc31bd7 commit 0813ff5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/formatNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function formatNumber(number, { decimals = 1, fallback = 'N/A' } = {}) {
return fallback
}
if (decimals) {
return `${int}.${dec || '0'}`
return `${int}.${Math.round(dec) || '0'}`
} else {
return String(Math.round(number))
}
Expand Down

0 comments on commit 0813ff5

Please sign in to comment.