(value: number, n = 1)
| 7 | // write a function that does the same as "number.toFixed(n)" |
| 8 | // but omit the trailing zeros |
| 9 | export function toFixed(value: number, n = 1) { |
| 10 | const str = value.toFixed(n) |
| 11 | if (str.indexOf('.') !== -1) { |
| 12 | return str.replace(/\.?0+$/, '') |
| 13 | } else { |
| 14 | return str |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | export function prettifyNumber(n: number, inChinese = false): string { |
| 19 | if (inChinese) { |