JAVA问题总结之7--Pow、sin、sqrt、abs等常用数学函数调用

JAVA问题总结之7--Pow、sin、sqrt、abs等常用数学函数调用


常用的使用方法:

Math.sin(0)		//返回0.0,这是double类型的值
Math.cos(0)		//返回1.0 
Math.tan(0.5)		//返回0.5463024898437905 
Math.round(6.6)		//返回7 
Math.round(6.3)		//返回6 
Math.ceil(9.2)		//返回10 .0
Math.ceil(-9.8)		//返回-9 .0
Math.floor(9.2)		//返回9 .0
Math.floor(-9.8)		//返回-10 .0
Math.sqrt(144)		//返回12.0 
Math.pow(5,2)		//返回25.0 
Math.exp(2)		//返回7.38905609893065 
Math.log(7.38905609893065)	//返回2.0 
Math.max(560, 289)	//返回560 
Math.min(560, 289)		//返回289 
Math.random()		//返回0.0到1.0之间双精度的一个随机数值

实践代码:

package p1;
public class test6 {
   public static void main(String[] args){
    System.out.println(Math.pow(10,155));
    System.out.println(Math.sin(1));
    System.out.println(Math.sin(Math.PI/4));
    System.out.println(Math.abs(-90));
    System.out.println(Math.sqrt(144));
    for (int i=1;i<=20;i++){
    	 System.out.println(i+":"+Math.random());    	
    }
   }
}

结果:

1.0E155
0.8414709848078965
0.7071067811865475
90
12.0
1:0.05260267431982091
2:0.6339033998766357
3:0.49012139821926204
4:0.6766536495850571
5:0.45268037837432784
6:0.3684743794849339
7:0.08980638896408366
8:0.7523227712481388
9:0.23355417326001215
10:0.41579450277636454
11:0.9330214794750951
12:0.10476091028343881
13:0.5372910349869016
14:0.4883949657729365
15:0.5738547396220067
16:0.9779399544828125
17:0.6946646075636851
18:0.3644623715046946
19:0.5593707918301456
20:0.15426893317772905

其他使用类推。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值