當前位置:生活全書館 >

IT科技

> arctan java

arctan java

<link rel="stylesheet" href="https://js.how234.com/third-party/SyntaxHighlighter/shCoreDefault.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/third-party/SyntaxHighlighter/shCore.js"></script><script type="text/javascript"> SyntaxHighlighter.all(); </script>

java arctan是什麼,讓我們一起了解一下?

arctan是java中數學運算的三角函式方法,tan() 三角正切,通過程式設計Java程式碼實現,常用的還有cos() 三角餘弦,sin()為 三角正弦,asin() 正弦的反函式,cos() 餘弦的反函式,tan() 正切的反函式。

java arctan

他的原始碼如下:

public class MainTest {    public static void main(String[] args) {        //求sin值        double sin = Math.sin(3.14);        System.out.println("sin3.14=" + sin);        //求cos值        double cos = Math.cos(0);        System.out.println("cos0=" + cos);        //求tan值        double tan = Math.tan(0.785);        System.out.println("tan0.785=" + tan);        //求arcsin        double arcsin = Math.asin(1);        System.out.println("arcsin1 = " + arcsin);        //求arccos        double arccos = Math.acos(1);        System.out.println("arccos = " + arccos);        //求arctan        double arctan = Math.atan(30);        System.out.println("arctan30 = " + arctan);        //求弧度        double radians = Math.toRadians(180);        System.out.println("180度角的弧度為" + radians);        //求角度        double angle = Math.toDegrees(3.141592653589793);        System.out.println("π的角度數為" + angle);        //求以e為底的指數        double exp = Math.exp(1);        System.out.println("以e為底指數為1的數為" + exp);        //求以e為底e的平方的對數        double log = Math.log(Math.E * Math.E);        System.out.println("以e為底e的平方的對數" + log);        //求以10為底100的對數        double log10 = Math.log10(100);        System.out.println("以10為底100的對數" + log10);        //求100的平方根        double sqrt = Math.sqrt(100);        System.out.println("100的平方根是" + sqrt);        //求27的立方根        double cbrt = Math.cbrt(27);        System.out.println("27的立方根是" + cbrt);        //求10除以3的餘數        double rest = Math.IEEEremainder(10, 3);        System.out.println("10除以3的餘數為" + rest);        //求0.9向上取整        double ceil = Math.ceil(0.9);        System.out.println("0.9向上取整" + ceil);        //求2.49向下取整        double floor = Math.floor(2.49);        System.out.println("2.49向下取整" + floor);        //求最接近引數的整數值(若有兩個滿足條件的資料則取為偶數的資料)        double rint = Math.rint(3.5);        System.out.println("最接近引數的整數值" + rint);        //獲得(1,1)座標與x軸夾角度數        double atan2 = Math.atan2(1, 1);        System.out.println("座標(1,1)的極座標為" + atan2);        //求3的5次方        double pow = Math.pow(3, 5);        System.out.println("3的5次方" + pow);        //4舍5入        double round = Math.round(3.5);        System.out.println("3.5四捨五入為" + round);        //計算2<<5+3<<4(會丟擲結果溢位異常)------- 2<<5:2乘以2的5次方 3<<4:3乘以2的4次方        int sum = Math.addExact(2 << 5, 3 << 4);        System.out.println("2<<5+3<<4=" + sum);        //計算2<<5-3<<4(會丟擲結果溢位異常)        int subTract = Math.subtractExact(2 << 5, 3 << 4);        System.out.println("2<<5-3<<4=" + subTract);        //計算2<<5*3<<4        int multiply = Math.multiplyExact(2 << 5, 3 << 4);        System.out.println("2<<5*3<<4=" + multiply);        //計算2<<5加1(會跑出溢位異常)        int increment = Math.incrementExact(2 << 5);        System.out.println("2<<5+1 = " + increment);        //計算2<<5加1(會跑出溢位異常)        int decrementExact = Math.decrementExact(2 << 5);        System.out.println("2<<5-1 = " + decrementExact);        //計算2<<5的相反數        int negate = Math.negateExact(2 << 5);        System.out.println("2<<5的相反數是" + negate);        //long轉int 2<<15        int intNum = Math.toIntExact(2 << 15L);        System.out.println(intNum);        //2&3 2在2進制中為10 3為11 & 表示相同位都為1則為1,其他為0 10&11 2進位制第二位都為1 所以 2&3=10=2        //multiplyHigh意義未知        //計算2<<5除以2<<4(取整)        int floorDiv = Math.floorDiv(2<<5,2<<4);        System.out.println("2<<5/2<<4="+floorDiv);        //取模運算(演算法與取餘相同,但負數運算是計算方式不同)        int floorMod = Math.floorMod(10,3);        System.out.println("10/3的模="+floorMod);        //取-52的絕對值        int abs = Math.abs(-52);        System.out.println("-52的絕對值="+abs);        //比較2<<5和3<<4的大小        int max = Math.max(2<<5,3<<4);        System.out.println("2<<5與3<<4相比,較大的數為"+max);        //比較2<<5和3<<4的大小        int min = Math.min(2<<5,3<<4);        System.out.println("2<<5與3<<4相比,較小的數為"+min);        //計算3乘5加4        double fma = Math.fma(3,5,4);        System.out.println("3乘5加4="+fma);    }}

輸出結果:

sin3.14=0.0015926529164868282cos0=1.0tan0.785=0.9992039901050427arcsin1 = 1.5707963267948966arccos = 0.0arctan30 = 1.5374753309166493180度角的弧度為3.141592653589793π的角度數為180.0以e為底指數為1的數為2.718281828459045以e為底e的平方的對數2.0以10為底100的對數2.0100的平方根是10.027的立方根是3.010除以3的餘數為1.00.9向上取整1.02.49向下取整2.0最接近引數的整數值4.0座標(1,1)的極座標為0.78539816339744833的5次方243.03.5四捨五入為4.02<<5+3<<4=1122<<5-3<<4=162<<5*3<<4=30722<<5+1 = 652<<5-1 = 632<<5的相反數是-64655362<<5/2<<4=210/3的模=1-52的絕對值=522<<5與3<<4相比,較大的數為642<<5與3<<4相比,較小的數為483乘5加4=19.0

以上就是小編今天的分享了,希望可以幫助到大家。

標籤: arctan java
  • 文章版權屬於文章作者所有,轉載請註明 https://shqsg.com/dianzi/wvn9xk.html