Math和StrictMath
来源:互联网 发布:淘宝月销售怎么查看 编辑:程序博客网 时间:2024/06/01 08:40
Math位于java.lang包下,当我们试图调用Math.sin方法时候,在Math类中显示的是StrictMath中的 sin方法
public static double sin(double a) {return StrictMath.sin(a); // default impl. delegates to StrictMath }
StrictMath中仅仅定义了方法,并且申明为static native
/** * Returns the trigonometric sine of an angle. Special cases: * <ul><li>If the argument is NaN or an infinity, then the * result is NaN. * <li>If the argument is zero, then the result is a zero with the * same sign as the argument.</ul> * * @param a an angle, in radians. * @return the sine of the argument. */ public static native double sin(double a);
在Math类中,为了达到最快的性能,所有的方法都使用计算机浮点单元中的历程。如果得到一个完全可预测的结果比运行速度更重要的话,就应该使用StrictMath类。它使用“自由发布的Math库”实现算法,以去报在所有平台上得到相同的结果。有关这些算法的源代码请参阅http://www.netlib.org/fdlibm/index.html
参考:
Math类还提供指数函数以及它的反函数--自然对数 Math.exp Math.log
Math类还提供了两个用于表示π和e常量的近似值 Math.PI Math.E
提示:从JDK5.0开始,不必在数学方法和常量名前添加前缀Math,而只用在源文件的顶部加上下列内容就可以 Import static java.lang.Math.*;
System.out.println("The square root of \u03C0 is "+sqrt(PI));
0 0
- Math和StrictMath
- Math与StrictMath
- Math与StrictMath的区别
- Math与StrictMath的区别
- Math.ceil()和Math.floor()、Math.round()
- Math.round, Math.ceil 和 Math.floor
- Math.ceil和Math.floor
- Math.cos()和Math.sin()和Math.atan()
- Math.floor和Math.ceil区别
- math.pow 和 Math.sqrt函数
- java.math.BinInteger和java.math.BigDecimal
- java.math.BigDecimal 和java.math.BigInteger
- Math.random()和Math.round()总结
- math.random()和Math.round的区别
- js Math.ceil()、Math.floor()和Math.round()
- Math.round和floor
- Math和Random类
- Date类和Math
- Eclipse快捷键 10个最有用的快捷键
- Java 反射是Java语言的一个很重要的特征,它使得Java具体了“动态性”。
- 《深入理解Linux内核》软中断/tasklet/工作队列
- Java文件上传与下载
- 阿里巴巴2014产品经理实习生提案五
- Math和StrictMath
- android sdk下载慢的解决方法
- 关于Android中调用系统拍照和剪裁,不能保存的问题
- Java文件上传与下载2
- ubuntu 下google浏览器的安装
- Storm实战之问题
- 使用JPublisher生成Oracle自定义类型的Java对象
- Ruby正则表达式修饰符
- 在线内核代码网站