Skip to content

Commit 4458154

Browse files
committed
updates
1 parent 049c755 commit 4458154

4 files changed

Lines changed: 1020 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
* [注解1](https://alleniverson.gitbooks.io/java-basic-introduction/content/第9章%20反射机制/注解.html)
9898
* [注解2](https://alleniverson.gitbooks.io/java-basic-introduction/content/第9章%20反射机制/Java注解.html)
9999
* [注解3](https://alleniverson.gitbooks.io/java-basic-introduction/content/第9章%20反射机制/Java注解Annotation基础.html)
100+
* [基础篇:带你从头到尾玩转注解](第9章 反射机制/基础篇:带你从头到尾玩转注解.md)
100101
* [编译时注解](https://alleniverson.gitbooks.io/java-basic-introduction/content/第9章%20反射机制/Annotation-Processing-Tool详解.html)
101102
* [依赖注入](https://alleniverson.gitbooks.io/java-basic-introduction/content/第9章%20反射机制/依赖注入.html)
102103
* [动态代理1](https://alleniverson.gitbooks.io/java-basic-introduction/content/第9章%20反射机制/动态代理.html)

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
* [注解1](第9章 反射机制/注解.md)
9595
* [注解2](第9章 反射机制/Java注解.md)
9696
* [注解3](第9章 反射机制/Java注解Annotation基础.md)
97+
* [基础篇:带你从头到尾玩转注解](第9章 反射机制/基础篇:带你从头到尾玩转注解.md)
9798
* [编译时注解](第9章 反射机制/Annotation-Processing-Tool详解.md)
9899
* [依赖注入](第9章 反射机制/依赖注入.md)
99100
* [动态代理1](第9章 反射机制/动态代理.md)

第2章 Java编程基础/Java语法基础-1.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,4 +676,95 @@ class OperatorDemo {
676676
```java
677677
int x=3,y=4,z;
678678
z = (x>y)?x:y;//z变量存储的就是两个数的大数。
679+
```
680+
## 7.8 Math
681+
682+
Math类提供了常用的一些数学函数,如:三角函数、对数、指数等。一个数学公式如果想用代码表示,则可以将其拆分然后套用Math类下的方法即可。
683+
684+
```java
685+
Math.abs(12.3); //12.3 返回这个数的绝对值
686+
Math.abs(-12.3); //12.3
687+
688+
Math.copySign(1.23, -12.3); //-1.23,返回第一个参数的量值和第二个参数的符号
689+
Math.copySign(-12.3, 1.23); //12.3
690+
691+
Math.signum(x); //如果x大于0则返回1.0,小于0则返回-1.0,等于0则返回0
692+
Math.signum(12.3); //1.0
693+
Math.signum(-12.3); //-1.0
694+
Math.signum(0); //0.0
695+
696+
697+
//指数
698+
Math.exp(x); //e的x次幂
699+
Math.expm1(x); //e的x次幂 - 1
700+
701+
Math.scalb(x, y); //x*(2的y次幂)
702+
Math.scalb(12.3, 3); //12.3*2³
703+
704+
//取整
705+
Math.ceil(12.3); //返回最近的且大于这个数的整数13.0
706+
Math.ceil(-12.3); //-12.0
707+
708+
Math.floor(12.3); //返回最近的且小于这个数的整数12.0
709+
Math.floor(-12.3); //-13.0
710+
711+
//x和y平方和的二次方根
712+
Math.hypot(x, y); //√(x²+y²)
713+
714+
//返回概述的二次方根
715+
Math.sqrt(x); //√(x) x的二次方根
716+
Math.sqrt(9); //3.0
717+
Math.sqrt(16); //4.0
718+
719+
//返回该数的立方根
720+
Math.cbrt(27.0); //3
721+
Math.cbrt(-125.0); //-5
722+
723+
//对数函数
724+
Math.log(e); //1 以e为底的对数
725+
Math.log10(100); //10 以10为底的对数
726+
Math.log1p(x); //Ln(x+ 1)
727+
728+
//返回较大值和较小值
729+
Math.max(x, y); //返回x、y中较大的那个数
730+
Math.min(x, y); //返回x、y中较小的那个数
731+
732+
//返回 x的y次幂
733+
Math.pow(x, y);
734+
Math.pow(2, 3); //即2³ 即返回:8
735+
736+
//随机返回[0,1)之间的无符号double值
737+
Math.random();
738+
739+
//返回最接近这个数的整数,如果刚好居中,则取偶数
740+
Math.rint(12.3); //12.0
741+
Math.rint(-12.3); //-12.0
742+
Math.rint(78.9); //79.0
743+
Math.rint(-78.9); //-79.0
744+
Math.rint(34.5); //34.0
745+
Math.rint(35.5); //36.0
746+
747+
Math.round(12.3); //与rint相似,返回值为long
748+
749+
//三角函数
750+
Math.sin(α); //sin(α)的值
751+
Math.cos(α); //cos(α)的值
752+
Math.tan(α); //tan(α)的值
753+
754+
//求角
755+
Math.asin(x/z); //返回角度值[-π/2,π/2] arc sin(x/z)
756+
Math.acos(y/z); //返回角度值[0~π] arc cos(y/z)
757+
Math.atan(y/x); //返回角度值[-π/2,π/2]
758+
Math.atan2(y-y0, x-x0); //同上,返回经过点(x,y)与原点的的直线和经过点(x0,y0)与原点的直线之间所成的夹角
759+
760+
Math.sinh(x); //双曲正弦函数sinh(x)=(exp(x) - exp(-x)) / 2.0;
761+
Math.cosh(x); //双曲余弦函数cosh(x)=(exp(x) + exp(-x)) / 2.0;
762+
Math.tanh(x); //tanh(x) = sinh(x) / cosh(x);
763+
764+
//角度弧度互换 360°角=2π弧度
765+
Math.toDegrees(angrad); //角度转换成弧度,返回:angrad * 180d / PI
766+
767+
Math.toRadians(angdeg); //弧度转换成角度,返回:angdeg / 180d * PI
768+
769+
Math.PI
679770
```

0 commit comments

Comments
 (0)