当前位置:网站首页>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
边栏推荐
猜你喜欢

Mini Program_Dynamic setting of tabBar theme skin

write the story about us
![[BJDCTF2020] EasySearch](/img/60/464de3bcdda876171b9f61ad31bff1.png)
[BJDCTF2020] EasySearch

Dephi reverse tool Dede exports function name MAP and imports it into IDA

LeetCode:1403. 非递增顺序的最小子序列【贪心】

动力小帆船制作方法简单,电动小帆船制作方法

Please write the SparkSQL statement
![[cesium] element highlighting](/img/99/504ca9802db83eb33bc6d91b34fa84.png)
[cesium] element highlighting

Redis哨兵模式配置文件详解

雷克萨斯lm的安全性到底体现在哪里?一起来看看吧
随机推荐
software management rpm
数字_获取指定位数的小数
ansible各个模块详解
软件管理rpm
Qixi Festival earn badges
8.04 Day35-----MVC三层架构
The solution to the failure to read channel information when dedecms generates a message in the background
Talk about 20 common problems in data governance
bytebuffer use demo
大学物理---质点运动学
狗仔队:表面编辑多视点图像处理
Redis - 13. Development Specifications
flex布局青蛙游戏通关攻略
App快速开发建设心得:小程序+自定义插件的重要性
Flutter学习4-基本UI组件
【学习笔记之菜Dog学C】动态内存管理之经典笔试题
【微信小程序】WXML模板语法-条件渲染
结构光三维重建(二)线结构光三维重建
1007 Climb Stairs (greedy | C thinking)
There are a lot of 4T hard drives remaining, prompting "No space left on device" insufficient disk space