RADIANS

Convert an angle from degrees to radians.

Category: mathReturns: DOUBLEDialect: Standard

Syntax

RADIANS(expr)

Description

## Overview Returns the input angle converted from degrees to radians. RADIANS multiplies by pi/180 (approximately 0.01745329). It is the required conversion step whenever you feed a degree-valued column into the SIN, COS, TAN, SEC, CSC, or COT trigonometric functions, all of which expect radians. For direct trigonometry on degree inputs, dialects that offer SIND, COSD, and TAND avoid the explicit RADIANS call and may return exact values at common angles (0, 30, 90, 180, 270) rather than the floating-point residue produced by the radians path. ## Behavior - Accepts any finite DOUBLE value. - Returns a DOUBLE equal to the input times pi/180. - Returns NULL if the argument is NULL. - Is exactly the inverse of DEGREES: RADIANS(DEGREES(x)) equals x to within one ULP. - Preserves sign: RADIANS(-90) = -pi/2. ## Numeric precision - Involves one multiplication by the constant pi/180, which introduces at most one ULP of rounding. - For exact angles (90, 180, 270, 360), the result is not exactly pi/2, pi, 3*pi/2, or 2*pi because pi is not exactly representable in DOUBLE. - For trig functions applied afterwards, the final output inherits the imprecision of both the pi conversion and the trig routine. ## Compatibility - Conforms to the SQL standard scalar function RADIANS. - Matches typical mathematical library implementations.

Parameters

NameTypeDescription
exprSpecifies the angle in degrees. Accepts any finite DOUBLE value. Negative and beyond-360 values are valid; the conversion is a pure multiplication by pi/180.

Examples

-- 180 degrees equals pi radians
SELECT RADIANS(180);
-- Result: 3.141592653589793
-- 90 degrees equals pi/2 radians
SELECT RADIANS(90);
-- Result: 1.5707963267948966
-- 45 degrees
SELECT RADIANS(45);
-- Result: 0.7853981633974483
-- Round-trip with DEGREES
SELECT RADIANS(DEGREES(1.0));
-- Result: 1.0
-- NULL propagation
SELECT RADIANS(NULL);
-- Result: NULL
-- Column use: feed a degree column into a trig function
SELECT sensor_id, SIN(RADIANS(azimuth_deg)) AS x_component
FROM iot.telemetry.compass_readings;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →