TAND

Compute the tangent of an angle supplied in degrees, with exact handling at common angles.

Category: numericReturns: DOUBLEDialect: PostgreSql

Syntax

TAND(degrees)

Description

## Overview Returns the tangent of an angle expressed in degrees. TAND avoids the RADIANS() conversion that TAN requires and is implemented to return mathematically exact values at 0, 45, 180, and 225 degrees. At the singular angles (90, 270, and all odd multiples of 90) the tangent is undefined; TAND typically returns a very large finite number or positive/negative infinity depending on the engine. For all other inputs, TAND is functionally identical to TAN(RADIANS(x)): inputs are cast to DOUBLE, the tangent is evaluated, and the result is a DOUBLE that can be any finite value or +/-infinity. ## Behavior - Accepts any numeric type implicitly castable to DOUBLE. - Returns a DOUBLE with unbounded magnitude. - Returns NULL if the argument is NULL. - Returns exact values at 0, 45, 180, 225 degrees. - At 90 and 270 degrees (and other odd multiples of 90), behavior depends on the engine: typically a very large finite number, or +/-infinity. - Preserves the anti-symmetric property: TAND(-x) = -TAND(x). ## Numeric precision - For canonical angles (0, 45, 180, 225), TAND returns the mathematically exact value. - For other angles, precision matches TAN(RADIANS(x)) plus the rounding in conversion. - Near the singularities at odd multiples of 90 degrees, small input changes produce large output swings. ## Compatibility - Matches the PostgreSQL TAND scalar function. - Complements TAN (radian input) and TAND (degree input) in dialects that offer both.

Parameters

NameTypeDescription
degreesSpecifies the angle in degrees. Accepts any numeric type implicitly castable to DOUBLE. The tangent is undefined at 90, 270, and all (2k+1)*90 degrees; evaluation near those values produces very large magnitudes.

Examples

-- Basic literal
SELECT TAND(0);  -- 0.0
-- Exact at 45 degrees
SELECT TAND(45);  -- 1.0
-- Exact at 180 degrees
SELECT TAND(180);  -- 0.0
-- Anti-symmetry
SELECT TAND(-45);  -- -1.0
-- Non-canonical angle
SELECT TAND(60);  -- 1.7320508075688767
-- Near singularity: TAND(90) returns a very large finite number or infinity depending on engine
SELECT TAND(89.999999);

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →