MCPcopy
hub / github.com/CaliCastle/cali.so / toFixed

Function toFixed

lib/math.ts:9–16  ·  view source on GitHub ↗
(value: number, n = 1)

Source from the content-addressed store, hash-verified

7// write a function that does the same as "number.toFixed(n)"
8// but omit the trailing zeros
9export 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
18export function prettifyNumber(n: number, inChinese = false): string {
19 if (inChinese) {

Callers 1

prettifyNumberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected