1.0.2 • Published 2 years ago

js-tofixed v1.0.2

Weekly downloads
12
License
ISC
Repository
github
Last release
2 years ago

js中Number类型的扩展

toFixed(len)

js浮点数的toFixed四舍五入,负数与正数执行相同的逻辑。-1.5返回-1,-1.6返回-2

toFixedMax(max)

最大小数位数 ,尾数为0的忽略

Number.floatAdd(a,b)

浮点相加

Number.floatSub(a,b)

浮点相减

Number.floatMul(a,b)

浮点相乘

Number.floatDiv(a,b)

浮点相除

NPMJS

npm install js-tofixed --save

Example

1.55.toFixed(1) => 1.6
(-1.55).toFixed(1) => 1.5
1.555.toFixedMax(2) => 1.56
1.5.toFixedMax(2) => 1.5
Number.floatSub(2.23,2.01) => 0.22
1.0.2

2 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago