atan java_Java StrictMath atan()用法及代码示例

java.lang.StrictMath.atan()是StrictMath类的内置方法,用于返回给定参数的切线。它返回的角度在-pi /2和pi /2的范围内。它产生两个特殊结果:

如果传递的参数为NaN,则输出为NaN。

如果传递的参数为0,则结果也是0,保留与参数相同的符号。

用法:

public static double atan(double num)

参数:该方法接受一个double类型的参数num,表示要返回其切线的值。

返回值:该方法返回参数的反正切值。

例子:

Input: num = 0.61

Output: 0.5477400137159024

Input: num = 0.0

Output: 0.0

Input: num = -71.0

Output: -1.5567127509720364

下面的程序演示了java.lang.StrictMath.atan()方法:

示例1:

// Java praogram to illustrate the

// java.lang.StrictMath.atan()

import java.lang.*;

public class Geeks {

public static void main(String[] args)

{

double num1 = 0.70, num2 = 55.00, num3 = 0;

double atanValue = StrictMath.atan(num1);

System.out.println("The arc tangent of " +

num1 + " = " + atanValue);

atanValue = StrictMath.atan(num2);

System.out.println("The arc tangent of " +

num2 + " = " + atanValue);

atanValue = StrictMath.atan(num3);

System.out.println("The arc tangent of " +

num3 + " = " + atanValue);

}

}

输出:

The arc tangent of 0.7 = 0.6107259643892086

The arc tangent of 55.0 = 1.5526165117219184

The arc tangent of 0.0 = 0.0

示例2:

// Java praogram to illustrate the

// java.lang.StrictMath.atan()

import java.lang.*;

public class Geeks {

public static void main(String[] args)

{

double num1 = -0.52, num2 = -71.00, num3 = 0;

double atanValue = StrictMath.atan(num1);

System.out.println("The arc tangent of " +

num1 + " = " + atanValue);

atanValue = StrictMath.atan(num2);

System.out.println("The arc tangent of " +

num2 + " = " + atanValue);

atanValue = StrictMath.atan(num3);

System.out.println("The arc tangent of " +

num3 + " = " + atanValue);

}

}

输出:

The arc tangent of -0.52 = -0.4795192919925962

The arc tangent of -71.0 = -1.5567127509720364

The arc tangent of 0.0 = 0.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值