java Math.cosでcos値を取得するサンプル

環境
Windows11 pro 64bit
java 19.0.1

概要
Math.cos(数値)
cos値を取得するには、「Math.cos」を使います

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
public class Main {
public static void main(String[] args) throws Exception {
System.out.println(Math.cos(Math.PI / 3));
System.out.println(Math.cos(Math.PI / 5));
}
}
public class Main { public static void main(String[] args) throws Exception { System.out.println(Math.cos(Math.PI / 3)); System.out.println(Math.cos(Math.PI / 5)); } }
public class Main {
    public static void main(String[] args) throws Exception {

        System.out.println(Math.cos(Math.PI / 3));  
        System.out.println(Math.cos(Math.PI / 5));  

    }
}

実行結果
0.5000000000000001
0.8090169943749475

IT

Posted by arkgame