当前位置:网站首页>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
边栏推荐
- Flutter 父子组件如何都能收到点击事件
- dedecms后台生成提示读取频道信息失败的解决方法
- span标签和p标签的区别
- [MRCTF2020] Ezpop (detailed)
- [cesium] 3D Tileset model is loaded and associated with the model tree
- 一篇博客通关Redis技术栈
- [informix] Resolving startup errors and solutions
- [8.3] Code Source - [meow ~ meow ~ meow~] [tree] [and]
- dedecms dream weaving tag tag does not support capital letters fix
- Feature preprocessing
猜你喜欢

Machine Learning Overview

The log causes these pits in the thread block, you have to guard against

特征预处理

Redis哨兵模式配置文件详解

Flutter learning 5-integration-packaging-publish

jvm 三 之堆与栈

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?

算法---一和零(Kotlin)

狗仔队:表面编辑多视点图像处理

结构光三维重建(二)线结构光三维重建
随机推荐
社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
[Nine Lectures on Backpacks - 01 Backpack Problems]
2023年信息与通信工程国际会议(JCICE 2023)
Cron(Crontab)--use/tutorial/example
逆向理论知识4
【informix】解决启动报错大全,以及解决办法
Four-digit display header design
[MRCTF2020] Ezpop (detailed)
结构光三维重建(二)线结构光三维重建
[8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]
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?
【 8.4 】 source code - [math] [calendar] [delete library 】 【 is not a simple sequence (Bonus) 】
C language - vernacular to understand the original code, inverse code and complement code
Flutter Learning 4 - Basic UI Components
dedecms织梦tag标签不支持大写字母修复
【转】什么是etcd
C#关于set()和get()方法的理解及使用
creo怎么测量点到面的距离
Cryptography Series: PEM and PKCS7, PKCS8, PKCS12
u-boot中的u-boot,dm-pre-reloc