How the Degrees() Function Works in PostgreSQL

In PostgreSQL, the degrees() function converts from radians to degrees.

The radian is the SI (International System of Units) unit for measuring angles. One radian is just under 57.3 degrees, and a full circle has just over 6.28 radians (2π).

Syntax

The syntax goes like this:

degrees(dp)

Where dp is a double precision value that represents the radians you want converted to degrees.

Example

Here’s an example of how it works.

SELECT degrees(5);

Result:

286.4788975654116

Here, we see that 5 radians is equal to 286.4788975654116 degrees.

Negative Values

You can also pass negative values.

SELECT degrees(-5);

Result:

-286.4788975654116

Expressions

Here’s an example that uses an expression.

SELECT degrees(2 * 3);

Result:

343.77467707849394

Large Values

You can pass values that are larger than a full circle.

SELECT degrees(2000);

Result:

114591.55902616464

Full Circle

In this example I provide the number of radians in a full circle.

SELECT degrees(6.283185307179586);

Result:

360

Pass Another Function

The previous example can also be done using the radians() function, which converts from degrees to radians.

SELECT degrees(radians(360));

Result:

360

Pi

As mentioned, a radian is 2π. We can use the pi() function to verify this.

SELECT 
  degrees(pi()),
  degrees(2 * pi());

Result:

 degrees | degrees
---------+---------
     180 |     360