当前位置:网站首页>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)
边栏推荐
- JVM栈和堆简介
- Simple implementation of slf4j
- C#读写应用程序配置文件App.exe.config,并在界面上显示
- [ue4] event distribution mechanism of reflective event distributor and active call event mechanism
- pytorch中常用数据集的使用方法
- Annual inventory review of Alibaba cloud's observable practices in 2021
- Advanced application of ES6 modular and asynchronous programming
- RuntimeError: “max_pool2d“ not implemented for ‘Long‘
- 2022-02-15 (399. Division evaluation)
- Talk about testdeploy
猜你喜欢
PR 2021 quick start tutorial, learn about the and functions of the timeline panel
[2020 overview] overview of link prediction based on knowledge map embedding
Pytorch(一) —— 基本语法
This sideline workload is small, 10-15k, free unlimited massage
OdeInt與GPU
【硬十宝典】——2.【基础知识】开关电源各种拓扑结构的特点
Pytorch(二) —— 激活函数、损失函数及其梯度
About the transmission pipeline of stage in spark
分布式数据库数据一致性的原理、与技术实现方案
C - detailed explanation of operators and summary of use cases
随机推荐
Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com. and
【硬十宝典目录】——转载自“硬件十万个为什么”(持续更新中~~)
Common UNIX Operation and maintenance commands of shell
LM小型可编程控制器软件(基于CoDeSys)笔记二十:plc通过驱动器控制步进电机
The longest increasing subsequence and its optimal solution, total animal weight problem
CF1638E. Colorful operations Kodori tree + differential tree array
2022危险化学品生产单位安全生产管理人员题库及答案
Pytorch(二) —— 激活函数、损失函数及其梯度
All in all, the low code still needs to solve these four problems
Tcp/ip explanation (version 2) notes / 3 link layer / 3.4 bridge and switch / 3.4.2 multiple registration protocol (MRP)
STM32扩展板 数码管显示
Pytorch(三) —— 函数优化
神经网络的基本骨架-nn.Moudle的使用
2022年聚合工艺考试题及模拟考试
Overview of the construction details of Meizhou veterinary laboratory
Selenium opens the Chrome browser and the settings page pops up: Microsoft defender antivirus to reset your settings
Software testing needs more and more talents. Why do you still not want to take this path?
Rule method: number of effective triangles
2022年上海市安全员C证考试题模拟考试题库及答案
软件研发的十大浪费:研发效能的另一面