当前位置:网站首页>js解决浮点数相乘精度丢失问题
js解决浮点数相乘精度丢失问题
2022-07-01 04:36:00 【进阶的巨人001】
例如
1.11 * 100 = 111.00000000000001
解决办法
export const format = function(f?, digit?) {
// 解决js精度丢失问题
// digit是保留几位小数
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
- Some small knowledge points
- Maixll-Dock 快速上手
- 一些小知识点
- 【硬十宝典】——1.【基础知识】电源的分类
- 2022 hoisting machinery command registration examination and hoisting machinery command examination registration
- 神经网络-非线性激活
- Obtain detailed ideas for ABCDEF questions of 2022 American Games
- Introduction to JVM stack and heap
- js 图片路径转换base64格式
猜你喜欢

How to do the performance pressure test of "Health Code"

Offline installation of Wireshark 2.6.10

Difficulties in the development of knowledge map & the importance of building industry knowledge map

Knowledge supplement: basic usage of redis based on docker

(12) Somersault cloud case (navigation bar highlights follow)

2022 t elevator repair new version test questions and t elevator repair simulation test question bank

The junior college students were angry for 32 days, four rounds of interviews, five hours of soul torture, and won Ali's offer with tears

About the transmission pipeline of stage in spark

Strategic suggestions and future development trend of global and Chinese vibration isolator market investment report 2022 Edition

LM small programmable controller software (based on CoDeSys) note 19: errors do not match the profile of the target
随机推荐
什么是uid?什么是Auth?什么是验证器?
[Master / slave] router election in DD message
How do I sort a list of strings in dart- How can I sort a list of strings in Dart?
Grey correlation cases and codes
Codeforces Round #771 (Div. 2) ABCD|E
Leecode records the number of good segmentation of 1525 strings
神经网络-卷积层
2022年煤气考试题库及在线模拟考试
2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis
TASK04|数理统计
1. Mobile terminal touch screen event
How to do the performance pressure test of "Health Code"
Difference between cookie and session
How to view the changes and opportunities in the construction of smart cities?
2022年化工自动化控制仪表操作证考试题库及答案
Shell之分析服务器日志命令集锦
[pat (basic level) practice] - [simple simulation] 1064 friends
细数软件研发效能的七宗罪
Annual inventory review of Alibaba cloud's observable practices in 2021
2022年T电梯修理题库及模拟考试