English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutoriel de base Java

Contrôle de flux Java

Java tableau

Java orienté objet (I)

Java orienté objet (II)

Java orienté objet (III)

Gestion des exceptions Java

Java Liste (List)

Java Queue (file d'attente)

Java Map collection

Java Set collection

Java entrée/sortie (I/O)

Reader Java/Writer

Autres sujets Java

Méthode d'utilisation et exemple de asin() de Math Java

Java Math mathematical methods

La méthode asin() de Math dans Java retourne l'arc sinus de la valeur spécifiée.

L'arc sinus est la fonction réciproque de la fonction sinus.

La syntaxe de la méthode asin() est :

Math.asin(double num)

paramètre asin()

  • num - au nombre à retourner son arc sinus

Note:La valeur absolue de num doit toujours être inférieure1

Valeur de retour de asin()

  • retourne l'arc sinus du nombre spécifié

  • si la valeur spécifiée est zéro, alors retourne 0

  • si le nombre spécifié est NaN ou supérieur1,retourne NaN

Note:La valeur de retour est -pi / 2 à pi / 2 entre les angles.

Example1:Java Math asin()

import java.lang.Math;
class Main {
  public static void main(String[] args) {
    //Create a variable
    double a = 0.99;
    double b = 0.71;
    double c = 0.0;
    //Print the arcsine value
    System.out.println(Math.asin(a));  // 1.4292568534704693
    System.out.println(Math.asin(b));  // 0.7812981174487247
    System.out.println(Math.asin(c));  // 0.0
  }
}

Dans l'exemple précédent, nous avons importé le paquet java.lang.Math. Si nous devons utiliser les méthodes de la classe Math, c'est très important. Notez l'expression

Math.asin(a)

Here, we use the class name directly to call the method. This is because asin() is a static method.

Example2: Math.asin() returns NaN

import java.lang.Math;
class Main {
  public static void main(String[] args) {
    // Create a variable
    double a = 2;
    //The square root of a negative number.
    //The result is not a number (NaN)
    double b = Math.sqrt(-5);
    //Print the arcsine value
    System.out.println(Math.asin(a));  // NaN
    System.out.println(Math.asin(b);  // NaN
  }
}

In this example, we have created two variables named a and b.

  • Math.asin(a) - Returns NaN because the value of a is greater than1

  • Math.asin(b) - Returns NaN because the negative number (-5) is not a number

Note:We have usedMath sqrt()method to calculate the square root of a number.

Java Math mathematical methods