public class Demo{
public static void main(String args[]){
/**
*Math.sqrt()//计算平方根
*Math.cbrt()//计算立方根
*Math.pow(a, b)//计算a的b次方
*Math.max( , );//计算最大值
*Math.min( , );//计算最小值
*/ System.out.println(Math.sqrt(16)); //4.0
System.out.println(Math.cbrt(8)); //2.0
System.out.println(Math.pow(3,2)); //9.0
System.out.println(Math.max(2.3,4.5));//4.5
System.out.println(Math.min(2.3,4.5));//2.3 /**
* abs求绝对值
*/
System.out.println(Math.abs(-10.4)); //10.4
System.out.println(Math.abs(10.1)); //10.1 /**
* ceil天花板的意思,就是返回大的值
*/
System.out.println(Math.ceil(-10.1)); //-10.0
System.out.println(Math.ceil(10.7)); //11.0
System.out.println(Math.ceil(-0.7)); //-0.0
System.out.println(Math.ceil(0.0)); //0.0
System.out.println(Math.ceil(-0.0)); //-0.0
System.out.println(Math.ceil(-1.7)); //-1.0 /**
* floor地板的意思,就是返回小的值
*/
System.out.println(Math.floor(-10.1)); //-11.0
System.out.println(Math.floor(10.7)); //10.0
System.out.println(Math.floor(-0.7)); //-1.0
System.out.println(Math.floor(0.0)); //0.0
System.out.println(Math.floor(-0.0)); //-0.0 /**
* random 取得一个大于或者等于0.0小于不等于1.0的随机数
*/
System.out.println(Math.random()); //小于1大于0的double类型的数
System.out.println(Math.random()*2);//大于0小于1的double类型的数
System.out.println(Math.random()*2+1);//大于1小于2的double类型的数 /**
* rint 四舍五入,返回double值
* 注意.5的时候会取偶数 异常的尴尬=。=
*/
System.out.println(Math.rint(10.1)); //10.0
System.out.println(Math.rint(10.7)); //11.0
System.out.println(Math.rint(11.5)); //12.0
System.out.println(Math.rint(10.5)); //10.0
System.out.println(Math.rint(10.51)); //11.0
System.out.println(Math.rint(-10.5)); //-10.0
System.out.println(Math.rint(-11.5)); //-12.0
System.out.println(Math.rint(-10.51)); //-11.0
System.out.println(Math.rint(-10.6)); //-11.0
System.out.println(Math.rint(-10.2)); //-10.0 /**
* round 四舍五入,float时返回int值,double时返回long值
*/
System.out.println(Math.round(10.1)); //10
System.out.println(Math.round(10.7)); //11
System.out.println(Math.round(10.5)); //11
System.out.println(Math.round(10.51)); //11
System.out.println(Math.round(-10.5)); //-10
System.out.println(Math.round(-10.51)); //-11
System.out.println(Math.round(-10.6)); //-11
System.out.println(Math.round(-10.2)); //-10
}
}

最新文章

  1. 50个C/C++源代码网站
  2. 深入理解CSS溢出overflow
  3. GNU make 升级
  4. USB HID描述符【转】
  5. 标准化命名CSS类,持续更新
  6. linux网站配置文件.htaccess伪静态转换到IIS web.config中
  7. HDU 4010 Query on The Trees(动态树)
  8. 学习设计模式之MVC、MVP、MVVM
  9. PHP 面试时常考的文件操作函数
  10. 智能合约语言 Solidity 教程系列7 - 以太单位及时间单位
  11. 猴子分桃—Python
  12. 使用kbmMWConfiguration 让 kbmmw smartservice 更聪明
  13. Make a plan, and stand for it!
  14. 【Spring】23、ApplicationContext ,ApplicationContextAware,Listener,Event 的关系解读
  15. Linux sort命令使用方法
  16. RecycleView 使用自定义CardLayouManager内容无法滚动问题
  17. Tidb数据库导入数据出现oom问题
  18. ios7新特性--1
  19. ADOX
  20. idea 设置

热门文章

  1. P3102 [USACO14FEB]秘密代码Secret Code
  2. gridview无数据源实现更新数据库(即断开更新数据库)
  3. Day 8 Linux之Day8
  4. meta标签集
  5. Ryuji doesn't want to study (树状数组)
  6. 洛谷——P2298 Mzc和男家丁的游戏
  7. OpenCV、PCL;Xtion、kinect;OpenNI、kinect for windows SDK比较
  8. [转] oracle里long类型的总结
  9. 加密算法和MD5等散列算法的区别(转)
  10. ubuntu harddisk uuid already exists