×

Java Math toRadians() Method

The toRadians() method of Java Math class converts an angle measured in degrees to an approximately equivalent angle measured in radian.

Syntax:

public static double toRadians (double angdeg)

Parameters

The parameter ‘angdeg’ represents an angle measured in degrees.

Return Value:

The toRadians() method returns the an inexact angdeg measurement in radians.

Example 1:

public class JavaMathToRadiansExample1 {
    public static void main(String[] args) {
        double a=67;
        //converts a degree angle to an approximately equivalent angle measured in radian
        System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
    }
}

Output:

Degree Angle 67.0 converted in radian = 1.1693705988362009

Example 2:

public class JavaMathToRadiansExample2 {
    public static void main(String[] args) {
        double a=Double.MIN_VALUE;
        //converts a degree angle to an approximately equivalent angle measured in radian
        System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
    }
}

Output:

Degree Angle 4.9E-324 converted in radian = 0.0

Example 3:

public class JavaMathToRadiansExample3 {
    public static void main(String[] args) {
        double a=-0d;
        //converts a degree angle to an approximately equivalent angle measured in radian
        System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
    }
}

Output:

Degree Angle -0.0 converted in radian = -0.0

Example 4:

public class JavaMathToRadiansExample4 {
    public static void main(String[] args) {
        double a=Double.NaN;
        //returns NaN, if the argument passed is NaN
        System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
    }
}

Output:

Degree Angle NaN converted in radian = NaN

Example 5:

public class JavaMathToRadiansExample5 {
    public static void main(String[] args) {
        double a=Double.NEGATIVE_INFINITY;
        //returns negative -infinity, if the argument passed is negative infinity
        System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
    }
}

Output:

Degree Angle -Infinity converted in radian = -Infinity

Related Topics

Java Pop

The array, linked list, stack, queue, and other data structures are supported by Java programming. The insertion, deletion, and element searching operations are available for every data structure. And Java...

4 minutes read.

Java Math expm1() Method

The expm1() method of Math class returns ex-1 where e represents Euler’s number. Syntax: public static double expm1(double x) Parameters: The parameter ‘x’ represents the exponent to raise e in the calculation of ex-1. Return...

2 minutes read.

Sleeping Barber Problem in Java

The barbershop in this issue has one barber, one barber chair, and N chairs for customers in the waiting area. We may demonstrate the issue by keeping with the original...

6 minutes read.

Frugal number in Java

A frugal number is a positive integer with base b that has more digits than the number of prime factors it can be factored into (including exponents greater than 1)....

3 minutes read.

Check whether a Number is a Power of 4 or Not in Java

There are many ways to figure out if an integer is a power of 4. This section will go over a variety of techniques for figuring out whether or not...

11 minutes read.

Java SHA256

Definition: In cryptography, SHA is a hash function that takes 20 bytes of input and produces an approximate 40-digit hexadecimal integer as the hash result. Class for Message Digest: Java's MessageDigest Class,...

2 minutes read.

Class vs Object in Java

Java : Java is a pure object oriented language. It was introduced by James Gosling in the year 1995. The first public implementation of java was done by sun micro systems...

7 minutes read.

How to run Java Program in Eclipse

How to run Java Program in Eclipse In this section, we will learn how to write, save, compile, and execute or run a Java program in Eclipse. Eclipse is one of...

2 minutes read.

Bean class in Java

The web applications that are created with the help of the JSP or Java Server Pages generally have fairly more functionality than the web pages that specifically are created with...

5 minutes read.

Getter and Setter Method in Java Example

In Java programming, getter and setter methods are often employed. The values of class fields can be accessed and changed using Java's getter and setter methods. A private access specifier...

6 minutes read.

ArrayList VS Linked List

ArrayList VS Linked List Both the ArrayList and LinkedList implements the List interface, and they have some differences as well as some similarities between them. The internal working and performance of both vary significantly. Let’s...

7 minutes read.

Java Calculate Average of List

The list is a linear data structure used in Java to store ordered data collections. Additionally, it accepts duplicate values while maintaining insertion order. It is sometimes necessary to find...

3 minutes read.

Add Time in Java

Before Java 8, java.util.Date was one of the most usually involved classes for addressing date-time values in java. Then Java 8 presented java.time.LocalDateTime and java.time.ZonedDateTime. Java 8 likewise permits us...

6 minutes read.

How to check Date Null in Java?

In this section, we will be acknowledged about Date Null in Java. The date null in Java is an entity that is used when there is no specified value for...

3 minutes read.

Difference between JDK, JRE and JVM In Java

In the Java ecosystem, three primary components are often mentioned: JDK, JRE, and JVM. Here’s a breakdown of each: Java Development Kit (JDK) The Java Development Kit (JDK) is a comprehensive software...

2 minutes read.

Java Null Keyword

Null is a term that is only used for literal values in Java. Although it appears to be a term, it is a literal opposite of true and false. Java's...

3 minutes read.

If Condition in Lambda Expression Java

The new and significant lambda expression feature of Java was added in Java SE 8. It provides a clear and concise mechanism for describing a single-method interface using an expression....

4 minutes read.

Three Partition Problems in Java

In talks with leading IT organizations like Google, Amazon, TCS, Accenture, etc., this extremely intriguing subject is constantly brought up. The goal of the problem-solving exercise is to evaluate the...

8 minutes read.

Upcasting in Java

To know what is Upcasting in Java we should first equip ourselves about what is casting or type casting in Java. Casting The process of providing or replacing a reference variable of...

3 minutes read.

Java Integer floatValue() method

The floatValue() method of Integer class returns a float value for this Integer after a widening primitive conversion. Syntax public float floatValue() Parameters NA Specified by This method is specified by floatValue in class Number Return Value This...

1 minute read.