当前位置:网站首页>number_gets the specified number of decimals
number_gets the specified number of decimals
2022-08-05 05:03:00 【good girl @@@】
保留小数_四舍五入
NumberThere is a method on the prototype chaintoFixed
[1]语法
number.toFixed([num])number为Number类型的数据
num为可选参数:表示要保留几位小数
- If notnum,默认不保留小数
- Rounding is done during rounding of decimals;
[2]返回值
The return value is the specified number of decimal places字符串;
[3]举例说明
11.123456.toFixed() // '11'
11.123456.toFixed(3) // '11.123'
11.123456.toFixed(4) // '11.1235'
保留小数_向下取整
[1]语法
Math.floor([num])
- floor方法的作用是获取numthe integer value and return it(Decrease the value directly to truncate the value before the decimal point)
- num为可选参数
- 不传,返回结果为NaN
- If it is not passedNumber类型,This method will convert the data to Numbertype to get an integer;
[2]返回值
返回Number类型的整数
[3]举例说明
// [1]获取整数
Math.floor(11.123456) // 11
// [2]获取3decimal integer
Math.floor(11.123456*1000)/1000 // 11.123
// [3]获取4Integer with decimal places
Math.floor(11.123456*10000)/10000 // 11.1234
保留小数_向上取整
[1]语法
Math.ceil([num])
- ceil方法的作用是获取numthe integer value and return it(向上取值-Add as long as there are decimals1)
- num为可选参数
- 不传,返回结果为NaN
- If it is not passedNumber类型,This method will convert the data to Numbertype to get an integer;
[2]返回值
返回Number类型的整数
[3]举例说明
// [1]获取整数
Math.ceil(11.123456) // 12
// [2]获取3decimal integer
Math.ceil(11.123456*1000)/1000 // 11.124
// [3]获取4Integer with decimal places
Math.ceil(11.123456*10000)/10000 // 11.1235
// [4]获取6Integer with decimal places
Math.ceil(11.123456*10000)/10000 // 11.123456
边栏推荐
- 1068 Find More Coins
- A 35-year-old software testing engineer with a monthly salary of less than 2W, resigns and is afraid of not finding a job, what should he do?
- 二叉树基本性质+oj题解析
- Detailed explanation of Mysql's undo log
- Detailed explanation of each module of ansible
- Dephi逆向工具Dede导出函数名MAP导入到IDA中
- 【cesium】Load and locate 3D Tileset
- uboot开启调试打印信息
- Use IDEA to connect to TDengine server
- 【转】什么是etcd
猜你喜欢

ESP32 485光照度

The role of DataContext in WPF

bytebuffer use demo

逆向理论知识4

Error creating bean with name ‘configDataContextRefresher‘ defined in class path resource

动力小帆船制作方法简单,电动小帆船制作方法
![[SWPU2019]Web1](/img/06/36e69a2d7d5475a6749a7d81edf50f.png)
[SWPU2019]Web1

Flutter真机运行及模拟器运行
![【 8.4 】 source code - [math] [calendar] [delete library 】 【 is not a simple sequence (Bonus) 】](/img/b5/716627b370e489ccf320a86540f7ba.png)
【 8.4 】 source code - [math] [calendar] [delete library 】 【 is not a simple sequence (Bonus) 】

u-boot调试定位手段
随机推荐
What is the function of industrial-grade remote wireless transmission device?
MySQL Foundation (1) - Basic Cognition and Operation
Cron(Crontab)--使用/教程/实例
[Nine Lectures on Backpacks - 01 Backpack Problems]
how to measure distance from point to face in creo
2023年信息与通信工程国际会议(JCICE 2023)
密码学系列之:PEM和PKCS7,PKCS8,PKCS12
Analyses the mainstream across technology solutions
The role of DataContext in WPF
【转】什么是etcd
[MRCTF2020] Ezpop (detailed)
Flutter Learning 4 - Basic UI Components
请写出SparkSQL语句
Flutter学习三-Flutter基本结构和原理
dedecms织梦tag标签不支持大写字母修复
Mini Program_Dynamic setting of tabBar theme skin
Is the NPDP certificate high in gold content?Compared to PMP?
数字孪生技术在电力系统中的应用现状
雷克萨斯lm的安全性到底体现在哪里?一起来看看吧
Detailed explanation of each module of ansible