java.lang.Math.toDegrees(แองกราดคู่) แปลงมุมที่วัดเป็นเรเดียนให้เป็นมุมที่เทียบเท่าโดยประมาณโดยวัดเป็นองศา การแปลงจากเรเดียนเป็นองศาโดยทั่วไปไม่แน่นอน ผู้ใช้ไม่ควรคาดหวังให้ cos(toRadians(90.0)) เท่ากับ 0.0
ในที่นี้ อาร์กิวเมนต์ angrad อยู่ในหน่วยเรเดียน
ตัวอย่าง
ต่อไปนี้คือตัวอย่างการใช้เมธอด toDegrees() ใน Java -
import java.lang.*;
public class Demo {
public static void main(String[] args) {
double x = 45;
double y = -180;
x = Math.toDegrees(x);
y = Math.toDegrees(y);
System.out.println("Math.tanh(" + x + ")=" + Math.tanh(x));
System.out.println("Math.tanh(" + y + ")=" + Math.tanh(y));
}
} ผลลัพธ์
Math.tanh(2578.3100780887044)=1.0 Math.tanh(-10313.240312354817)=-1.0
ตัวอย่าง
เรามาดูตัวอย่างกัน −
import java.lang.*;
public class Demo {
public static void main(String[] args) {
double x;
x = Math.PI;
System.out.println(Math.toDegrees(x));
}
} ผลลัพธ์
180.0