当前位置:网站首页>JS foundation 5
JS foundation 5
2022-06-28 10:53:00 【Programmer community】
Math
Math Object as a storage mathematical formula , Information and Computing
attribute
| attribute | Method |
|---|---|
| Math.E | Base of natural logarithm e Value |
| Math.LN10 | With 10 The natural logarithm of the base |
| Math.LOG2E | With 2 Bottom e The logarithmic |
| Math.PI | π Value |
| Math.max() | Maximum |
| Math.min() | minimum value |
| Math.ceil() | Rounding up |
| Math.floor() | Rounding down |
| Math.round() | Round to the nearest whole |
| Math.fround() | Return to the nearest (32 position ) Floating point value |
| Math.random() | 0~1 Between random numbers |
| Math.abs() | Return the absolute value |
| Math.log() | Return to the natural logarithm |
notes :
Math.random() Random number but excluding 1
Built in Math The operation is faster than custom functions
Base number
Integers can be expressed in octal or hexadecimal literal
- Octal must be preceded by 0
var num=016
console.log(num)
// result 14
var num=019
console.log(num)
// Invalid octal 10 Base number 19 Handle
- Hexadecimal must be preceded by 0x( Case sensitive )
var num=0x16
console.log(num)
// result 22
parseInt() It can recognize the value of different base numbers
notes :parseFloat() Only decimal numbers can be parsed
- 0 The following values will be interpreted as octal
var num=parseInt(016)
console.log(num)
// result 14
- 0x The values that follow are interpreted as hexadecimal
var num=parseInt(0x16)
console.log(num)
// result 22
toString() It can return numbers in different hexadecimals by passing in parameters
var num=16
console.log(num.toString())
// result 16
console.log(num.toString(2))
// result 10000
console.log(num.toString(8))
// result 20
console.log(num.toString(10))
// result 16
console.log(num.toString(16))
// result 10
边栏推荐
猜你喜欢

Katalon framework tests web (XX) custom keywords and upload pop-up operations

数据库系列:有什么办法对数据库的业务表进行无缝升级

Realization of a springboard machine

Dataease installation upgrade

Ruoyi integrated building block report (NICE)
Ribbon核心源码解析

Markdown -- basic usage syntax

Day 6 script and animation system

移动命令

Mysql database overview and installation process
随机推荐
乌国家安全与国防委员会秘书:将对俄境内目标进行精确打击
建立自己的网站(11)
Metersphere实现UI自动化元素不可点击(部分遮挡)
How to use K-line diagram for technical analysis
线程和线程池
2022 Wu Enda machine learning specialization week 2 practice lab: linear expression
Using loops for, while, and if in katalon else、break、continue
方法重写(Override)
Metersphere uses JS to refresh the current page
Katalon全局变量在TestObject引用
【功能建议】多个工作空间启动时选择某个空间
一款自动生成单元测试的 IDEA 插件,开发效率提升 70% 以上!
Ble Bluetooth module nrf518/nrf281/nrf528/nrf284 chip scheme comparison
appliedzkp zkevm(9)中的Bytecode Proof
Mongo database
Six fusion positioning technologies in wireless communication application of Internet of things
To enhance the function of jupyter notebook, here are four tips
Yann LeCun新论文:构建自动智能体之路
vsftpd服务的部署及优化
sentinel