当前位置:网站首页>JS to solve the problem of floating point multiplication precision loss
JS to solve the problem of floating point multiplication precision loss
2022-07-01 04:44:00 【Advanced giant 001】
for example
1.11 * 100 = 111.00000000000001
terms of settlement
export const format = function(f?, digit?) {
// solve js Loss of accuracy
// digit It's to keep a few decimal places
const m = Math.pow(10, digit);
return Math.round(f * m) / m;
};
format(1.11 * 100)
边栏推荐
- Research on medical knowledge atlas question answering system (I)
- 2022危险化学品生产单位安全生产管理人员题库及答案
- 神经网络的基本骨架-nn.Moudle的使用
- Daily question - line 10
- VIM简易使用教程
- STM32扩展板 数码管显示
- JS rotation chart
- Web server: how to choose a good web server these five aspects should be paid attention to
- Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling
- 2022 gas examination question bank and online simulation examination
猜你喜欢

2022 G2 power station boiler stoker examination question bank and G2 power station boiler stoker simulation examination question bank

C - detailed explanation of operators and summary of use cases

2022危险化学品生产单位安全生产管理人员题库及答案

VIM简易使用教程

Applications and features of VR online exhibition

2022 question bank and answers for safety production management personnel of hazardous chemical production units

TCP server communication flow

Pytorch(四) —— 可视化工具 Visdom

2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis

无器械健身
随机推荐
The design points of voice dialogue system and the importance of multi round dialogue
2022年化工自动化控制仪表操作证考试题库及答案
Odeint and GPU
Take a cold bath
Thoughts on the construction of Meizhou cell room
Common UNIX Operation and maintenance commands of shell
[FTP] the solution to "227 entering passive mode" during FTP connection
Leecode records the number of good segmentation of 1525 strings
常用的Transforms中的方法
Odeint et GPU
Advanced application of ES6 modular and asynchronous programming
MySQL winter vacation self-study 2022 12 (5)
Rule method: number of effective triangles
js解决浮点数相乘精度丢失问题
Openresty rewrites the location of 302
Applications and features of VR online exhibition
Why is Hong Kong server most suitable for overseas website construction
LeetCode_35(搜索插入位置)
LeetCode_53(最大子数组和)
Quelques outils dont les chiens scientifiques pourraient avoir besoin