Java 教程 Java tan() 方法

webb · 2022-05-24 23:07:19 · 热度: 11

tan() 方法用于返回指定double类型参数的正切值。

语法

double tan(double d)

参数

  • d -- 任何原生数据类型。

返回值

返回指定double类型参数的正切值。

实例

public class Test{
    public static void main(String args[]){

        double degrees = 45.0;
        double radians = Math.toRadians(degrees);

        System.out.format("pi 的值为 %.4f%n", Math.PI);
        System.out.format("%.1f 度的正切值是 %.4f%n", degrees, Math.tan(radians));

    }
}

编译以上程序,输出结果为:

pi 的值为 3.1416
45.0 度的正切值是 1.0000

查看更多 Java Number & Math 类 相关内容

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册