Perl Tutorial Perl References

Perl Math - rad2deg() Function



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

Syntax

rad2deg(x)

Parameters

x Specify an angle in radians to convert.

Return Value

The degree equivalent of an angle in radians.

Example:

In the example below, rad2deg() function is used to convert an angle in radians to an angle in degrees.

use Math::Trig;

print("rad2deg(pi/6) = ".rad2deg(pi/6)."\n");
print("rad2deg(pi/4) = ".rad2deg(pi/4)."\n");
print("rad2deg(pi/3) = ".rad2deg(pi/3)."\n");
print("rad2deg(pi/2) = ".rad2deg(pi/2)."\n");
print("rad2deg(pi) = ".rad2deg(pi)."\n");

The output of the above code will be:

rad2deg(pi/6) = 30
rad2deg(pi/4) = 45
rad2deg(pi/3) = 60
rad2deg(pi/2) = 90
rad2deg(pi) = 180

❮ Perl Math Functions