math对象常用于执行数学任务
常用的属性
Math对象常用的函数
alert(Math.round(3.5));四舍五入alert(Math.random());随机0~1之间随机数Math.max();返回较大数Math.min();返回较小的数alert(Math.max(10,20,30));alert(Math.abs(-10));返回绝对值Math.ceil();向上取整Math.floor();向下取整alert(Math.ceil(3.1));//4alert(Math.floor(3.9));//3Math.pow(x,y);求x的y次方,x是底数,y是指数Math.sqrt();开平方alert(Math.sqrt(4));//2
Math对象与勾股函数
【注】本身计算器有bug,计算小数的时候,会出错。
银行的计数单位是分(double),没有小数点
参数:都应该是弧度。 Math.PI = 180弧度
1弧度 = Math.PI / 180;
Math.sin()/cos()/tan();//正弦/余弦/正切alert(Math.sin(90 * Math.PI / 180));alert(Math.cos(60 * Math.PI / 2));
