首页 > 其他 > 详细

math类

时间:2017-02-16 23:18:32      阅读:191      评论:0      收藏:0      [点我收藏+]

成员方法

 


* public static int abs(int a)//取绝对值

* public static double ceil(double a)//向上取整

* public static double floor(double a)//向下取整

* public static int max(int a,int b) min自学 //取出最大值

* public static double pow(double a,double b)//计算a的b次方

* public static double random()//随机出0.0~1.0之间的随机数 ,不包含1.0

* public static int round(float a) 参数为double的自学 //四舍五入

* public static double sqrt(double a)//开平方

 


如何获取一个1-100之间的随机数?

int number = (int)(Math.random()*100)+1;

注:random():返回带正号的 double 值,该值大于等于 0.0 且小于 1.0。


math类

原文:http://www.cnblogs.com/loaderman/p/6407213.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!