Skip to content

js精度,js浮点数,js浮点数计算,js计算精度问题解决方案,js保留小数位,

License

Notifications You must be signed in to change notification settings

rumengkai/js-float-accuracy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

float-accuracy.js@1.0.0

install float-accuracy.js

npm install js-float-accuracy

use js-float-accuracy.js

node import

const accuracy=require('js-float-accuracy');

import accuracy from 'js-float-accuracy'

// division(除法) 

console.log(accuracy.div(0.1,0.1));		// 1

// multiplication(乘法) 

console.log(accuracy.mul(0.1,0.1));		// 0.01

// addition(加法) 

console.log(accuracy.add(0.1,0.1));		// 0.2

// subtraction(减法) 

console.log(accuracy.sub(0.1,0.1));		// 0

// 末位进1保留小数,第二个参数传入保留位数

console.log(accuracy.toCeil(0.01234, 4)); // 0.0124

// 末位舍掉保留小数,第二个参数传入保留位数

console.log(accuracy.toFloor(0.01235, 4)); // 0.0123

script label

<script src="~/js-float-accuracy/index.js">
// to do ...
// adopt window.accuracy use
</script>

float-accuracy.js@1.0.0

About

js精度,js浮点数,js浮点数计算,js计算精度问题解决方案,js保留小数位,

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published