Perl Tutorial Perl References

Perl Math - deg2rad() Function



The Perl Math deg2rad() function is used to convert an angle in degrees to an angle in radians.

Syntax

deg2rad(x)

Parameters

x Specify an angle in degrees to convert.

Return Value

The radian equivalent of an angle in degrees.

Example:

In the example below, deg2rad() function is used to convert an angle in degree to an angle in radian.

use Math::Trig;

print("deg2rad(30) = ".deg2rad(30)."\n");
print("deg2rad(45) = ".deg2rad(45)."\n");
print("deg2rad(60) = ".deg2rad(60)."\n");
print("deg2rad(90) = ".deg2rad(90)."\n");
print("deg2rad(180) = ".deg2rad(180)."\n");

The output of the above code will be:

deg2rad(30) = 0.523598775598299
deg2rad(45) = 0.785398163397448
deg2rad(60) = 1.0471975511966
deg2rad(90) = 1.5707963267949
deg2rad(180) = 3.14159265358979

❮ Perl Math Functions