当前位置:网站首页>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
边栏推荐
- Is the NPDP certificate high in gold content?Compared to PMP?
- 请写出SparkSQL语句
- No regrets, the appium automation environment is perfectly built
- [informix] Resolving startup errors and solutions
- 延迟加载js方式async与defer区别
- Cryptography Series: PEM and PKCS7, PKCS8, PKCS12
- software management rpm
- [8.3] Code Source - [meow ~ meow ~ meow~] [tree] [and]
- NPDP证书含金量高吗?跟PMP相比?
- Flutter learning three-Flutter basic structure and principle
猜你喜欢

Develop your own node package
![[MRCTF2020] Ezpop (detailed)](/img/19/920877ca36d1eda8d118637388ab05.png)
[MRCTF2020] Ezpop (detailed)

creo怎么测量点到面的距离

No regrets, the appium automation environment is perfectly built

类的底层机制

Analyses the mainstream across technology solutions

作业8.4 进程间的通信 管道与信号
![【 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) 】

Qt制作18帧丘比特表白意中人、是你的丘比特嘛!!!

大学物理---质点运动学
随机推荐
【cesium】3D Tileset 模型加载并与模型树关联
JeeSite New Report
【cesium】加载并定位 3D Tileset
ansible各个模块详解
延迟加载js方式async与defer区别
Learning and finishing of probability theory 8: Geometric and hypergeometric distributions
[informix] Resolving startup errors and solutions
Flutter学习三-Flutter基本结构和原理
Error creating bean with name ‘configDataContextRefresher‘ defined in class path resource
结构光三维重建(二)线结构光三维重建
密码学系列之:PEM和PKCS7,PKCS8,PKCS12
【转】什么是etcd
社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
Flutter learning three-Flutter basic structure and principle
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?
Flutter学习2-dart学习
[cesium] element highlighting
逆向理论知识4
flink reads mongodb data source
作业8.4 进程间的通信 管道与信号