strictmath_Java StrictMath sin()方法与示例

strictmath

StrictMath类sin()方法 (StrictMath Class sin() method)

  • sin() method is available in java.lang package.

    sin()方法在java.lang包中可用。

  • sin() method is used to return the trigonometric sine of the given parameter in the method.

    sin()方法用于返回方法中给定参数的三角正弦值。

  • In this method, sin stands for trigonometric sine of an angle".

    在这种方法中, sin代表一个角度的三角正弦”。

  • sin() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get any error.

    sin()方法是静态方法,可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会收到任何错误。

  • In this method we pass only radians type argument (i.e. First we convert given argument in radians by using toRadians() method of StrictMath class then after we will pass the same variable in sin() method).

    在此方法中,我们仅传递弧度类型的参数(即,首先,我们使用StrictMath类的toRadians()方法将给定的参数转换为弧度,然后在sin()方法中传递相同的变量)。

  • sin() method does not throw any exception at the time of returning trigonometric sine of an angle.

    在返回角度的三角正弦时, sin()方法不会引发任何异常。

Syntax:

句法:

    public static double sin(double d);

Parameter(s):

参数:

  • double d – represents the value whose trigonometric sine is to be returned.

    double d –表示要返回其三角正弦值的值。

Return value:

返回值:

The return type of this method is double – it returns the trigonometric sine of given angle.

这种方法的返回类型是双 -它返回给定的角度的正弦值。

Note:

注意:

  • If we pass NaN, the method returns NaN.

    如果传递NaN,则该方法返回NaN。

  • If we pass an infinity, the method returns NaN.

    如果传递无穷大,则该方法返回NaN。

  • If we pass a value whose absolute value is 0, the method returns 0.

    如果传递绝对值为0的值,则该方法返回0。

Example:

例:

// Java program to demonstrate the example of 
// sin(double d) method of StrictMath class.

public class Sin {
    public static void main(String[] args) {
        // variable declarations
        double a1 = 100;
        double a2 = Math.PI / 2;
        double a3 = 0;

        // Display previous value of a1, a2 and a3
        System.out.println("a1: " + a1);
        System.out.println("a2: " + a2);
        System.out.println("a3: " + a3);

        // By using toRadians() method is used to convert absolute to radians
        a2 = StrictMath.toRadians(a2);

        // Display the value of a2 in radians form
        System.out.println("StrictMath.toRadians(a2): " + a2);

        // Here we will find trignometric sine of a2 
        // by using sin() method
        System.out.println("StrictMath.sin(a2): " + StrictMath.sin(a2));

        // Here , we will get 0 because we are passing parameter 
        // whose absolute value is 0
        System.out.println("StrictMath.sin(a3): " + StrictMath.sin(a3));
    }
}

Output

输出量

a1: 100.0
a2: 1.5707963267948966
a3: 0.0
StrictMath.toRadians(a2): 0.027415567780803774
StrictMath.sin(a2): 0.027412133592044294
StrictMath.sin(a3): 0.0


翻译自: https://www.includehelp.com/java/strictmath-sin-method-with-example.aspx

strictmath

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值