Add helper function to convert to fixed-point string

This commit is contained in:
Chocobo1 2019-07-22 14:23:05 +08:00
parent 60faba60ea
commit 19b8a52e44
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
2 changed files with 10 additions and 8 deletions

View file

@ -161,3 +161,9 @@ function safeTrim(value) {
throw e;
}
}
function toFixedPointString(number, digits) {
// Do not round up number
const power = Math.pow(10, digits);
return (Math.floor(power * number) / power).toFixed(digits);
}