Math类测试

//Math类测试

 

/**
 *<p>项目名称:  Java</p>
 *<p>文件名称:  MathTest</p>
 *<p>版权所有:  版权所有(C)2008-2010</p>
 *<p>公    司:   

 *<p>编写日期: 2008-7-11上午09:07:55</p>
 *<p>作    者:  huangtao</p>
 */

/**
 * @author huangtao
 *
 */
public class MathTest
{

 /**
  * @param args
  */
 public static void main(String[] args)
 {
  //Math字段属性
  System.out.println(Math.E);
  System.out.println(Math.PI);
  
  //数的立方根的值
  System.out.println(Math.cbrt(27d));
  
  //以e为底的基数次幂的值
  System.out.println(Math.exp(1));
  System.out.println(Math.exp(2)-Math.expm1(2));
  System.out.println(Math.E*Math.E-Math.expm1(2));
  
  //数的边界值
  System.out.println(Math.floor(1.2));
  System.out.println(Math.ceil(1.2));
  
  //两数的平方和的开方的值
  System.out.println(Math.ceil(Math.hypot(2 , 3)));
  
  //两数的平方和的值
  System.out.println(Math.ceil(Math.hypot(2 , 3)*Math.hypot(2 , 3)));
  System.out.println(Math.ceil(Math.hypot(2 , 3)*Math.hypot(2 , 3))==13);
  
  //数的模
  System.out.println(Math.IEEEremainder(6 , 3));
  System.out.println(6%3);
  
  //以10为底的对数的值
  System.out.println(Math.log(10d));
  System.out.println(Math.log10(10d));
  System.out.println(Math.log1p(10d));
  
  //数的n次幂的值
  System.out.println(Math.pow(Math.E , 3));
  System.out.println(Math.exp(3));
  
  //随机数
  System.out.println(Math.random());
  
  
  //返回接近参数的double值
  System.out.println(Math.rint(10d));
  
  //四舍五入
  System.out.println(Math.round(10d));
  System.out.println(Math.round(10f));
  
  //返回参数的ulp大小
  System.out.println(Math.ulp(10d));
  System.out.println(Math.ulp(10f));
  
  //获取包的名字
  System.out.println(Package.getPackage("langtest"));

 }
}

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值