開心生活站

位置:首頁 > IT科技 > 

java,arccos

IT科技2.79W

<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 arccos是什麼,讓我們一起了解一下?

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

java arccos

他的源代碼如下:

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

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

標籤:java arccos