当前位置:网站首页>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)
边栏推荐
- Section 27 remote access virtual private network workflow and experimental demonstration
- 神经网络-最大池化的使用
- Maixll dock quick start
- Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling
- TASK04|數理統計
- How to do the performance pressure test of "Health Code"
- Task04 mathematical statistics
- The index is invalid
- 做网站数据采集,怎么选择合适的服务器呢?
- 2022 G2 power station boiler stoker examination question bank and G2 power station boiler stoker simulation examination question bank
猜你喜欢

OdeInt与GPU

Knowledge supplement: basic usage of redis based on docker

Pytest automated testing - compare robotframework framework

Shell之一键自动部署Redis任意版本

Annual inventory review of Alibaba cloud's observable practices in 2021

Grey correlation cases and codes

Extension fragment
![[2020 overview] overview of link prediction based on knowledge map embedding](/img/69/22983c5f37bb67a8dc0e2b87c73238.jpg)
[2020 overview] overview of link prediction based on knowledge map embedding

Leetcode learning - day 36

2022危险化学品生产单位安全生产管理人员题库及答案
随机推荐
CF1638E colorful operations
VIM easy to use tutorial
[leetcode skimming] February summary (updating)
LM小型可编程控制器软件(基于CoDeSys)笔记十九:报错does not match the profile of the target
Use winmtr software to simply analyze, track and detect network routing
Common UNIX Operation and maintenance commands of shell
AssertionError assert I.ndim == 4 and I.shape[1] == 3
Some small knowledge points
What are permissions? What are roles? What are users?
离线安装wireshark2.6.10
Programs and processes, process management, foreground and background processes
2022年聚合工艺考试题及模拟考试
This sideline workload is small, 10-15k, free unlimited massage
Openresty rewrites the location of 302
网站服务器:好用的网站服务器怎么选这五方面要关注
[godot] unity's animator is different from Godot's animplayer
MySQL winter vacation self-study 2022 12 (5)
Selenium opens the Chrome browser and the settings page pops up: Microsoft defender antivirus to reset your settings
数据加载及预处理
Leetcode learning - day 36