Java Math toRadians()

Learn via video course
FREE
View all courses
Java Course - Mastering the Fundamentals
Java Course - Mastering the Fundamentals
by Tarun Luthra
1000
5
Start Learning
Java Course - Mastering the Fundamentals
Java Course - Mastering the Fundamentals
by Tarun Luthra
1000
5
Start Learning
Topics Covered

Overview

An angle measured in degrees can be converted into an approximately equivalent angle measured in radians using toRadians() method defined in the java.lang.Math class.

  • This method will return NaN(Not a Number) if the argument is NaN.
  • This method will return zero with the same sign as the argument if the argument is zero.
  • This method will return infinite with the same sign as the input if the argument is infinite.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Syntax of Math toRadians() in Java

The syntax of the toRadians() method is:

Parameters of Math toRadians() in Java

The toRadians() method takes only one parameter.

angle - The angle in degrees that needs to be converted into radians.

Return Value of Math toRadians() in Java

  • Returns the angle measured in radians
  • Return type is double
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Exceptions of Math toRadians() in Java

Math.toRadians() does NOT throw any exception.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example

Note: To convert any given angle from the measure of degrees to radians, the value has to be multiplied by π/180.

In this example we are going to see how to use/call Math.toRadians() method in java.

Output:

Explanation:

  • In the above code we have simply converted the angle in Degrees to Radians using Math.toRadians() method of Math class.
  • As we know, 180 degrees is equal to π radians. Hence, an approximate value of π is printed.

What is Math toRadians() in Java?

An angle measured in Degrees is converted to a roughly comparable angle measured in Radians using the toRadians() method defined in java.lang.Math class. Degrees to Radian conversions are typically not accurate.

  • This method will return NaN if the argument is NaN.
  • This method will return zero with the same sign as the argument if the argument is zero.
  • This method will return Infinity with the same sign as the input if the argument is Infinity.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

More Examples

Example 1

In this example, we are going to see how to convert degrees to radians in java using toRadians() method in java.

Output:

Explanation:

In the above code, we have converted 90 and 45 degrees to radians.

Example 2

In this example, we are going to use toRadians() method in java with NaN.

Output:

Explanation:

  • As we have discussed above already that toRadians() will return NaN when NaN is passed as argument. So NaN is printed here.

Note: When a negative number is passed as input to Math.sqrt() method, NaN is returned.

Example 3

In this example, we are going to see how to use Math.toRadians() in Java with Infinity as argument.

Output:

Conclusion

  • An angle measured in Degrees is converted to a roughly comparable angle measured in Radians using the java.lang.Math.toRadians() method.
  • Degrees to Radians conversions are typically not accurate.
  • This method will return NaN if the argument is NaN.
  • This method will return zero with the same sign as the argument if the argument is zero.
  • This method will return Infinity with the same sign as the input if the argument is Infinity.