English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Java Math Mathematical Methods
O método Math.atan() do Java retorna o valor arco tangente do número especificado.
A tangente inversa é a função inversa da tangente.
A sintaxe do método atan() é:
Math.atan(double num)
num - O número a retornar a função arco tangente
Retorna o arco tangente do número especificado
Se o valor especificado for zero, retorna 0
Se o valor especificado for NaN, retorna NaN
NoteA função de retorno é -pi / 2 até pi / 2 entre os ângulos.
import java.lang.Math; class Main { public static void main(String[] args) { //Create a variable double a = 0.99; double b = 2.0; double c = 0.0; //Print the arctangent value System.out.println(Math.atan(a)); // 0.7803730800666359 System.out.println(Math.atan(b)); // 1.1071487177940904 System.out.println(Math.atan(c)); // 0.0 } }
In the above example, we have imported the java.lang.Math package. This is important if we want to use the methods of the Math class. Note the expression
Math.atan(a)
Here, we used the class name directly to call the method. This is because atan() is a static method.
import java.lang.Math; class Main { public static void main(String[] args) { //Create a variable //Square root of a negative number //The result is not a number (NaN) double a = Math.sqrt(-5); //Print the arctangent value System.out.println(Math.atan(a)); // NaN } }
Here, we created a variable named a.
Math.atan(a) - Returns NaN because a negative number (-5) whose square root is not a number
Note:We have already usedJava Math sqrt()Method to calculate the square root of a number.