981377660LMT / ts

ts学习
6 stars 1 forks source link

math.round 函数 #444

Open 981377660LMT opened 7 months ago

981377660LMT commented 7 months ago
golang: math.round(-2.5) => -3
python,javascript: round(-2.5) => -2
981377660LMT commented 7 months ago

不同语言中 round 函数实现不同,js 里是 +0.5 后向下取整。

981377660LMT commented 7 months ago

numerify 库也留了一个 roundingFunction 的参数位置,专门用来自定义 roundingFunction 逻辑

981377660LMT commented 7 months ago
type NumerifyLike = (input: number | string | null | undefined, formatType?: string, roundingFunction?: (value: number) => number) => string;