Math 对象

math对象用于执行数学任务

Math 常用的属性 Math.PI 约等于3.14159

Math对象的常用函数

Math.round()
四舍五入
alert(Math.round(3.4)); //3

Math.random()
随机数
alert(Math.random()); //随机0~1之间的随机数

Math.max()
返回较大的数
alert(Math.max(10 , 20 , 30)); // 30

Math.min()
返回较小的数
alert(Math.min(10 , 20 , 30)); //10

Math.abs()
返回当前值()的绝对值
alert(Math.abs(-10)); //10

Math.ceil()
向上取整
alert(Math.ceil(3.1415)); // 4

Math.floor()
向下取整
alert(Math.floor(3.9415)); // 3

Math.pow(x , y)
求x的y次方
alert(Math.pow(2 ,3)); //8

Math.sqrt();
开平方的
alert(Math.sqrt(9)); //3

Math对象勾股函数
**【注】**本身计算机有BUG,计算小数的时候,会出错。
银行的计数单位是分,没有小数点。

Math对象勾股函数
参数:都应该是弧度。
Math.PI = 180弧度
1弧度 = Math.PI / 180

Math.sin() //求正弦
Math.cos() //求余弦
Math.tan() //求正切

求30度的正弦
alert(Math.sin(30*Math.PI / 180));

求90度的正弦
alert(Math.sin(90*Math.PI / 180));

求180度的正弦
alert(Math.sin(Math.PI / 2));

算60度的余弦值
alert(Math.cos(60*Math.PI / 180));

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值