Oracle COS Function with ExamplesIn this article, we look at the Oracle COS function and see some examples.

Purpose of the Oracle COS Function

The COS function will return the cosine of a number.

If your knowledge of cosine is a bit rusty (like mine), then you might find this definition helpful.

 

Syntax

The syntax of the COS function is:

COS (number)

 

Parameters

The parameters of the COS function are:

  • number (mandatory): This is the number to convert into a cosine.

The number can be any numeric data typeThe return value is in the same data type as the specified data type, unless the specified data type is BINARY_FLOAT. In that case, the return type is BINARY_DOUBLE.

 

Examples of the COS Function

Here are some examples of the COS function. The three examples are quite similar, as the syntax is simple, but they use different numbers as input.

Example 1

SELECT COS(3.141) AS cos_value
FROM dual;

Result:

COS_VALUE
-0.9999998244

 

Example 2

SELECT COS(1) AS cos_value
FROM dual;

Result:

COS_VALUE
0.540302305

 

Example 3

SELECT COS(5.2) AS cos_value
FROM dual;

Result:

COS_VALUE
0.46851667

 

Similar Functions

Some functions which are similar to the COS function are:

  • SIN: Returns the sine of a number.
  • TAN: Returns the tangent of a number.
  • COSH: Returns the hyperbolic cosine of a number.
  • SINH: Returns the hyperbolic sine of a number.
  • TANH: Returns the hyperbolic tangent of a number.

If you want to know more about SQL functions, you can find a full list of Oracle SQL functions here.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

Improve Your Oracle SQL With My 10-Day Email Course

x