目录

static double sin(double a)

描述 (Description)

java.lang.Math.sin(double a)一个角度的三角正弦。 特殊情况 -

  • 如果参数是NaN或无穷大,则结果为NaN。

  • 如果参数为零,则结果为零,其参数符号相同。

声明 (Declaration)

以下是java.lang.Math.sin()方法的声明

public static double sin(double a)

参数 (Parameters)

a - 以弧度表示的角度。

返回值 (Return Value)

此方法返回参数的正弦值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了lang.Math.sin()方法的用法。

package com.iowiki;
import java.lang.*;
public class MathDemo {
   public static void main(String[] args) {
      // get two double numbers numbers
      double x = 45;
      double y = -180;
      // convert them to radians
      x = Math.toRadians(x);
      y = Math.toRadians(y);
      // print the trigonometric sine for these doubles
      System.out.println("Math.sin(" + x + ")=" + Math.sin(x));
      System.out.println("Math.sin(" + y + ")=" + Math.sin(y));
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

Math.sin(0.7853981633974483)=0.7071067811865475
Math.sin(-3.141592653589793)=-1.2246467991473532E-16
↑回到顶部↑
WIKI教程 @2018