strictmath_Java StrictMath toRadians()方法与示例

strictmath

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

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

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

  • toRadians() method is used to convert the angle from degrees to radians or in other words this method is used to convert an angle measured in degrees to an equivalent angle measured in radians.

    toRadians()方法用于将角度从度转换为弧度,换句话说,此方法用于将以度为单位的角度转换为以弧度为单位的等效角度。

  • toRadians() method is a static method so 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.

    toRadians()方法是一个静态方法,因此可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会出现任何错误。

  • toRadians() method does not throw any exception at the time of conversion of an angle from degree to radians.

    在将角度从度转换为弧度时, toRadians()方法不会引发任何异常。

  • The result of conversion an angle from degrees to radians is not generally exact.

    将角度从度转换为弧度的结果通常不准确。

Syntax:

句法:

    public static double toRadians(double ang_in_deg);

Parameter(s):

参数:

  • double ang_in_deg – represents an angle in degrees.

    double ang_in_deg –表示以度为单位的角度。

Return value:

返回值:

The return type of this method is double – it returns the radians converted value of the given angle (in degrees).

这种方法的返回类型是双 -它返回弧度给定角度(度)的转换后的值。

Example:

例:

// Java program to demonstrate the example of 
// toRadians(double ang_in_deg) method of StrictMath class.

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

        // Variable Declarations
        double d1 = 60;
        double d2 = -60;
        double d3 = 90;
        double d4 = -90;

        // Display previous value of d1,d2,d3 and d4
        System.out.println("d1: " + d1);
        System.out.println("d2: " + d2);
        System.out.println("d3: " + d3);
        System.out.println("d4: " + d4);

        // By using toRadians() method is used to convert the given angle
        // from degrees into radians

        d1 = StrictMath.toRadians(d1);
        d2 = StrictMath.toRadians(d2);
        d3 = StrictMath.toRadians(d3);
        d4 = StrictMath.toRadians(d4);

        System.out.println("StrictMath.toRadians(d1): " + d1);
        System.out.println("StrictMath.toRadians(d2): " + d2);
        System.out.println("StrictMath.toRadians(d3): " + d3);
        System.out.println("StrictMath.toRadians(d4): " + d4);
    }
}

Output

输出量

d1: 60.0
d2: -60.0
d3: 90.0
d4: -90.0
StrictMath.toRadians(d1): 1.0471975511965976
StrictMath.toRadians(d2): -1.0471975511965976
StrictMath.toRadians(d3): 1.5707963267948966
StrictMath.toRadians(d4): -1.5707963267948966


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

strictmath

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值