Math 数学的方法

Math

    // console.log(Math);// 对象;

    
1. Math.max : 获取一组数的最大值
     //console.log(Math.max(12, 3, 45, 109, 4));//109

    
2.Math.min
     //console.log(Math.min(12, 3, 0, 109, 4));//0

    
3. Math.floor : 向下取整
     //console.log(Math.floor(4.999));//4
     //console.log(Math.floor(-4.999));//-5

    
4.Math.ceil() : 向上取整
     //console.log(Math.ceil(4.01));// 5
     //console.log(Math.ceil(-4.01));// -4

   
5.Math.round() : 四舍五入;保留整数;
     console.log(Math.round(4.499));//4

   
6.Math.random();产生一个[0,1)的随机小数;
     //console.log(Math.random());
     Math
.random()产生一个m--n之间的随机整数;
     //Math.round(Math.random()*(n-m)+m);
     //Math.round(Math.random()*(90-40)+40)

   
7.Math.pow() :取数字的幂次方Math.pow(n,m) n的m次方
    //console.log(Math.pow(2, 6));64

   
8.Math.sqrt() :开平方
    //console.log(Math.sqrt(64));//8

   
9.Math.abs() :对负数取绝对值;
    //console.log(Math.abs(-12));//12

   
10.Infinity 无穷大  -Infinity无穷小

转载于:https://www.cnblogs.com/MrZhujl/p/9937605.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值