深入学习java源码之Math.sin()与 Math.sqrt()

native关键字

凡是一种语言,都希望是纯。比如解决某一个方案都喜欢就单单这个语言来写即可。Java平台有个用户和本地C代码进行互操作的API,称为JNI

native关键字告诉编译器(其实是JVM)调用的是该方法在外部定义,这里指的是C。

Modifier and TypeMethod and Descriptionstatic doubleacos(double a) 返回值的反余弦值; 返回的角度在0.0到pi的范围内。 static intaddExact(int x, int y) 返回其参数的总和,如果结果溢出int,则抛出 int 。 static longaddExact(long x, long y) 返回其参数的总和,如果结果溢出long,则抛出 long 。 static doubleasin(double a) 返回值的正弦值; 返回角度在pi / 2到pi / 2的范围内。 static doubleatan(double a) 返回值的反正切值; 返回角度在pi / 2到pi / 2的范围内。 static doubleatan2(double y, double x) 返回从直角坐标(转换角度 theta x , y )为极坐标 (R,θ-)。 static doublecbrt(double a) 返回 double值的多维数据集根。 static doubleceil(double a) 返回大于或等于参数的最小(最接近负无穷大) double值,等于一个数学整数。 static doublecopySign(double magnitude, double sign) 使用第二个浮点参数的符号返回第一个浮点参数。 static floatcopySign(float magnitude, float sign) 使用第二个浮点参数的符号返回第一个浮点参数。 static doublecos(double a) 返回角度的三角余弦。 static doublecosh(double x) 返回的双曲余弦 double值。 static doubleexp(double a) 返回欧拉的数字 e提高到一个 double价值。 static doubleexpm1(double x) 返回 e x -1。 static doublehypot(double x, double y) 返回sqrt( x 2 + y 2 ),没有中间溢出或下溢。 static doublelog(double a) 返回的自然对数(以 e为底) double值。 static doublelog10(double a) 返回一个 double的基数10对数值。 static doublelog1p(double x) 返回参数和1的和的自然对数。 static doublepow(double a, double b) 将第一个参数的值返回到第二个参数的幂。 static doublerandom() 返回值为 double值为正号,大于等于 0.0 ,小于 1.0 。 static doublerint(double a) 返回与参数最接近值的 double值,并且等于数学整数。 static longround(double a) 返回参数中最接近的 long ,其中 long四舍五入为正无穷大。 static intround(float a) 返回参数中最接近的 int ,其中 int四舍五入为正无穷大。 static doublesin(double a) 返回角度的三角正弦。 static doublesinh(double x) 返回的双曲正弦 double值。 static doublesqrt(double a) 返回的正确舍入正平方根 double值。 static doubletan(double a) 返回角度的三角正切。 static doubletanh(double x) 返回的双曲正切 double值。 static doubleulp(double d) 返回参数的ulp的大小。 static floatulp(float f) 返回参数的ulp的大小。

java源码

public final class Math {

private Math() {}

public static final double E = 2.7182818284590452354;

public static final double PI = 3.14159265358979323846;

public static double sin(double a) {

return StrictMath.sin(a); // default impl. delegates to StrictMath

}

public static double cos(double a) {

return StrictMath.cos(a); // default impl. delegates to StrictMath

}

public static double tan(double a) {

return StrictMath.tan(a); // default impl. delegates to StrictMath

}

public static double asin(double a) {

return StrictMath.asin(a); // default impl. delegates to StrictMath

}

public static double acos(double a) {

return StrictMath.acos(a); // default impl. delegates to StrictMath

}

public static double atan(double a) {

return StrictMath.atan(a); // default impl. delegates to StrictMath

}

public static double exp(double a) {

return StrictMath.exp(a); // default impl. delegates to StrictMath

}

public static double log(double a) {

return StrictMath.log(a); // default impl. delegates to StrictMath

}

public static double log10(double a) {

return StrictMath.log10(a); // default impl. delegates to StrictMath

}

public static double sqrt(double a) {

return StrictMath.sqrt(a); // default impl. delegates to StrictMath

// Note that hardware sqrt instructions

// frequently can be directly used by JITs

// and should be much faster than doing

// Math.sqrt in software.

}

public static double cbrt(double a) {

return StrictMath.cbrt(a);

}

public static double IEEEremainder(double f1, double f2) {

return StrictMath.IEEEremainder(f1, f2); // delegate to StrictMath

}

public static double atan2(double y, double x) {

return StrictMath.atan2(y, x); // default impl. delegates to StrictMath

}

public static double pow(double a, double b) {

return StrictMath.pow(a, b); // default impl. delegates to StrictMath

}

public static double sinh(double x) {

return StrictMath.sinh(x);

}

public static double cosh(double x) {

return StrictMath.cosh(x);

}

public static double tanh(double x) {

return StrictMath.tanh(x);

}

public static double hypot(double x, double y) {

return StrictMath.hypot(x, y);

}

public static double expm1(double x) {

return StrictMath.expm1(x);

}

public static double log1p(double x) {

return StrictMath.log1p(x);

}

}

public final class StrictMath {

private StrictMath() {}

public static final double E = 2.7182818284590452354;

public static final double PI = 3.14159265358979323846;

public static native double sin(double a);

public static native double cos(double a);

public static native double tan(double a);

public static native double asin(double a);

public static native double acos(double a);

public static native double atan(double a);

public static strictfp double toRadians(double angdeg) {

// Do not delegate to Math.toRadians(angdeg) because

// this method has the strictfp modifier.

return angdeg / 180.0 * PI;

}

public static strictfp double toDegrees(double angrad) {

// Do not delegate to Math.toDegrees(angrad) because

// this method has the strictfp modifier.

return angrad * 180.0 / PI;

}

public static native double exp(double a);

public static native double log(double a);

public static native double log10(double a);

public static native double sqrt(double a);

public static native double cbrt(double a);

public static native double IEEEremainder(double f1, double f2);

public static native double atan2(double y, double x);

public static native double pow(double a, double b);

public static native double sinh(double x);

public static native double cosh(double x);

public static native double tanh(double x);

public static native double hypot(double x, double y);

public static native double expm1(double x);

public static native double log1p(double x);

}

Math源码java_深入学习java源码之Math.sin()与 Math.sqrt()相关推荐

  1. 深入学习java源码之Math.max()与 Math.min()

    深入学习java源码之Math.max()与 Math.min() java基本数据类型及自动转型 8种基本数据类型及其所占空间大小: 一.byte,占用一个字节,取值范围为 -128-127,默认是 ...

  2. 深入学习java源码之Math.addExact()与 Math.multiplyExact()

    深入学习java源码之Math.addExact()与 Math.multiplyExact() ^运算符 或的运算符,其运算规则是: 两个操作数的位中,相同则结果为0,不同则结果为1. int i ...

  3. 转载:深入学习java源码之Callable.call()与Future.get()

    原始链接:https://blog.csdn.net/qq_35029061/article/details/86750369 深入学习java源码之Callable.call()与Future.ge ...

  4. 深入学习java源码之 Arrays.sort()与Arrays.parallelPrefix()

    深入学习java源码之 Arrays.sort()与Arrays.parallelPrefix() Comparator接口 能对不同类型的对象进行排序(当然排序依据还是基本类型),也不用自己实现排序 ...

  5. java在线客服系统源码 springboot客服聊天源码 网页客服源码 netty通信技术,java源码

    ava在线客服系统源码 springboot客服聊天源码 网页客服源码 netty通信技术,java源码 Java在线客服系统源码 企业网站客服聊天源码 网页客服源码 开发环境:Java + Spri ...

  6. 如何学习java源码

    刚才在论坛不经意间,看到有关源码阅读的帖子.回想自己前几年,阅读源码那种兴奋和成就感(1),不禁又有一种激动. 源码阅读,我觉得最核心有三点:技术基础+强烈的求知欲+耐心. 说到技术基础,我打个比方吧 ...

  7. 【java集合框架源码剖析系列】java源码剖析之java集合中的折半插入排序算法

    注:关于排序算法,博主写过[数据结构排序算法系列]数据结构八大排序算法,基本上把所有的排序算法都详细的讲解过,而之所以单独将java集合中的排序算法拿出来讲解,是因为在阿里巴巴内推面试的时候面试官问过 ...

  8. 昆山培训java_昆山学习java要来这里

    Java是一门面向对象编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承.指针等概念,因此Java语言具有功能强大和简单易用两个特征.Java语言作为静态面向对象编程语言的代表 ...

  9. java 字节码对象_通过java字节码分析学习对象初始化顺序

    mockery.checking(new Expectations() { { one(new Object()).toString(); will(returnValue("") ...

最新文章

  1. 最小二乘法和最大似然估计
  2. 使用fiddler4做代理调试手机页面
  3. 2020年ACM Fellows出炉!颜水成、周昆、陈怡然等12位华人当选
  4. 搜索Idiot就出现特朗普图片,算法无罪!
  5. linux大小写敏感 mysql_MySQL大小写敏感问题和命名规范
  6. Spring Boot 2.0 利用 Spring Security 实现简单的OAuth2.0认证方式1
  7. kibana一直弹出来报错?
  8. Python学习 Day 046 - DOM 操作 二
  9. 查看android数据库sqlite3中的表及数据、直接编辑数据库
  10. 提交显示成功但是没有看到文件_如何向RTThread提交一个BSP?
  11. LeetCode 1835. 所有数对按位与结果的异或和(位运算 (ab)^(ac) = a(b^c) )
  12. 校招刷题---java选择题笔记05
  13. 雇佣黑客组织利用 3Ds Max 恶意软件攻击全球企业
  14. 网络诈骗有哪些防范措施
  15. 推荐一款专家级网站流量分析软件-逆火(Nihuo)
  16. 交换机组播风暴_cisco 交换机端口广播风暴设置(非常详细)
  17. 设计模式解密(17)- 备忘录模式
  18. 如何使用git上传项目至GitHub repository
  19. 【转载】PyCharm 或者其他 Idea 官网打不开解决办法:
  20. 办公利器!用Python批量识别发票并录入到Excel表格

热门文章

  1. maskView与CAGradientLayer那回事儿
  2. C#动态加载dll,dll目录指定
  3. 002 模板实参推断、重载与模板
  4. 七 web爬虫讲解2—urllib库爬虫—状态吗—异常处理—浏览器伪装技术、设置用户代理...
  5. Linux 系统目录
  6. GIS二次开发之初探
  7. mac 下用 brew 安装mongodb
  8. ES5-拓展 this指向的总结
  9. View的绘制-layout流程详解
  10. Python基础知识-05-数据类型总结字典