当前位置:网站首页>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)
边栏推荐
- Grey correlation cases and codes
- 2022 G2 power station boiler stoker examination question bank and G2 power station boiler stoker simulation examination question bank
- Caijing 365 stock internal reference | the first IPO of Beijing stock exchange; the subsidiary of the recommended securities firm for gambling and gambling, with a 40% discount
- 【硬十宝典目录】——转载自“硬件十万个为什么”(持续更新中~~)
- Leecode question brushing record 1332 delete palindrome subsequence
- Summary of acl2021 information extraction related papers
- Ten wastes of software research and development: the other side of research and development efficiency
- Pytorch(二) —— 激活函数、损失函数及其梯度
- How to do the performance pressure test of "Health Code"
- How do I sort a list of strings in dart- How can I sort a list of strings in Dart?
猜你喜欢

Why is Internet thinking not suitable for AI products?

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

分布式数据库数据一致性的原理、与技术实现方案

pytorch中常用数据集的使用方法

2022.2.7-2.13 AI industry weekly (issue 84): family responsibilities

STM32 extended key scan

2022 a special equipment related management (elevator) simulation test and a special equipment related management (elevator) certificate examination

Question bank and answers for chemical automation control instrument operation certificate examination in 2022

Research on medical knowledge atlas question answering system (I)

VR线上展览所具备应用及特色
随机推荐
Leecode records the number of good segmentation of 1525 strings
Grey correlation cases and codes
2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis
细数软件研发效能的七宗罪
Simple implementation of slf4j
JS image path conversion Base64 format
2022 G2 power station boiler stoker examination question bank and G2 power station boiler stoker simulation examination question bank
Strategic suggestions and future development trend of global and Chinese vibration isolator market investment report 2022 Edition
Leecode record 1351 negative numbers in statistical ordered matrix
神经网络-使用Sequential搭建神经网络
分布式数据库数据一致性的原理、与技术实现方案
Talk about testdeploy
神经网络-卷积层
CUDA development and debugging tool
Common interview questions ①
VIM简易使用教程
Summary of testing experience - Testing Theory
OdeInt与GPU
Maixll dock quick start
Question bank and online simulation examination for special operation certificate of G1 industrial boiler stoker in 2022