Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

perl
math
radians
degrees
communitycreator

What is deg2rad() in Perl?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The deg2rad() function in Perl converts a value in degrees to an equal value in radians.

Figure 1 below shows a mathematical representation of the deg2rad() function.

Figure 1: Mathematical representation of deg2rad() function

The Math::Trig module is required for this function.

Syntax


deg2rad(number)

Parameter

The deg2rad() function takes a numberdegree value as a parameter.

Return value

The deg2rad() function converts the degree value sent as a parameter to a value in radians.

Code

use Math::Trig;

#180
print "deg2rad(180) : " .deg2rad(180). " Radians \n";

#0
print "deg2rad(0) : " .deg2rad(0). " Radians \n";

#--180
print "deg2rad(-180) : " .deg2rad(-180). " Radians \n";

RELATED TAGS

perl
math
radians
degrees
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring