Oracle ATAN2() Function

Oracle ATAN2() is a built-in function that returns the arc tangent of two given arguments.

Oracle ATAN2() syntax

Here is the syntax for the Oracle ATAN2() function:

ATAN2(x, y)

Parameters

x

Required.

y

Required.

Return Value

The Oracle ATAN2() function returns the arctangent of the two given parameters. It is a value in the range -pi to pi, expressed in radians.

if any parameter is BINARY_FLOAT or BINARY_DOUBLE, ATAN2() returns BINARY_DOUBLE. Otherwise ATAN2() returns NUMBER.

If any parameter is NULL, ATAN2() will return NULL.

Oracle ATAN2() Examples

Here are some examples that demonstrate the usage of the Oracle ATAN2() function.

Basic Usage

SELECT
    ATAN2(1, 2)
FROM dual;

Output:

                                   ATAN2(1,2)
_____________________________________________
   0.4636476090008061162142562314612144020295

NULL Parameter

If any parameter is NULL, ATAN2() will return NULL.

SET NULL 'NULL';
SELECT
    ATAN2(1, NULL) NULL1,
    ATAN2(NULL, 1) NULL2,
    ATAN2(NULL, NULL) NULL3
FROM dual;

Output:

   NULL1    NULL2    NULL3
________ ________ ________
    NULL     NULL     NULL

In this example, we use the statement SET NULL 'NULL'; to display NULL values as the string 'NULL'.

Conclusion

Oracle ATAN2() is a built-in function that returns the arc tangent of two given arguments.