Skip to main content

ACOS (SQL)

A scalar numeric function that returns the arc-cosine, in radians, of a given cosine.

Synopsis

{fn ACOS(numeric-expression)}

Description

ACOS takes a numeric value and returns the inverse (arc) of its cosine as a floating point number. The value of numeric-expression must be a signed decimal number ranging from 1 to -1 (inclusive). A number outside of this range causes a runtime error, generating an SQLCODE -400 (fatal error occurred). ACOS returns NULL if passed a NULL value. ACOS treats nonnumeric strings, including the empty string (''), as the numeric value 0.

ACOS returns a value with a precision of 19 and a scale of 18.

ACOS can only be used as an ODBC scalar function (with the curly brace syntax).

You can use the DEGREES function to convert radians to degrees. You can use the RADIANS function to convert degrees to radians.

Arguments

numeric-expression

A numeric expression whose value is between -1 and 1. This is the cosine of the angle.

ACOS returns either the NUMERIC or DOUBLE data type. If numeric-expression is data type DOUBLE, ACOS returns DOUBLE; otherwise, it returns NUMERIC.

Examples

The following examples show the effect of ACOS on two cosines:

SELECT {fn ACOS(0.52)} AS ArcCosine 

returns 1.023945...

SELECT {fn ACOS(-1)} AS ArcCosine

returns pi (3.14159...).

See Also

FeedbackOpens in a new tab