当前位置:网站首页>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)
边栏推荐
- One click shell to automatically deploy any version of redis
- Sorting out 49 reports of knowledge map industry conference | AI sees the future with wisdom
- 先有网络模型的使用及修改
- STM32 photoresistor sensor & two channel AD acquisition
- 2022 G2 power station boiler stoker examination question bank and G2 power station boiler stoker simulation examination question bank
- STM32扩展板 温度传感器和温湿度传感器的使用
- LeetCode_35(搜索插入位置)
- Difference between cookie and session
- CF1638E. Colorful operations Kodori tree + differential tree array
- 技术分享| 融合调度中的广播功能设计
猜你喜欢
JS image path conversion Base64 format
JVM栈和堆简介
STM32 光敏电阻传感器&两路AD采集
Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling
STM32扩展板 数码管显示
Rule method: number of effective triangles
分布式锁的实现
2022 Shanghai safety officer C certificate examination question simulation examination question bank and answers
OdeInt与GPU
无器械健身
随机推荐
Shell之一键自动部署Redis任意版本
Simple implementation of slf4j
Basic usage, principle and details of session
JS image path conversion Base64 format
Research on medical knowledge atlas question answering system (I)
Leecode question brushing record 1332 delete palindrome subsequence
Leecode record 1351 negative numbers in statistical ordered matrix
神经网络-最大池化的使用
Measurement of quadrature axis and direct axis inductance of three-phase permanent magnet synchronous motor
[difficult] sqlserver2008r2, can you recover only some files when recovering the database?
2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis
总结全了,低代码还需要解决这4点问题
软件研发的十大浪费:研发效能的另一面
Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling
Basic exercise of test questions hexadecimal to decimal
How to use maixll dock
Shell之分析服务器日志命令集锦
Pytest automated testing - compare robotframework framework
2022年T电梯修理题库及模拟考试
Dede collection plug-in does not need to write rules