Saturday, July 19, 2008

Numeric ABS ACOS ASIN ATAN ATAN2 BITAND CEIL COS COSH functions

1)ABS
The ABS function takes any numeric datatype or any nonnumeric datatype (that can be implicitly converted to a numeric datatype) as an argument and return the absolute value of the datatype.

It takes only single value as argument.

Syntax:ABS(n)
Example:
SQL>Select ABS(-100) FROM DUAL;
ABS(-100)
----------
100

2)ACOS

We all know that cos60 degree=.5 and 180 degree=pi redian=3.1416 (approx). ACOS returns the arc cosine of n. n must be in the range of -1 to 1 as we know the value of cosine can very between +1 to -1. Here ACOS function returns a value in the range of 0 to pi, expressed in radians.

Example:
Here result will appear in redians (by default)
SQL> select acos(.5) from dual;
ACOS(.5)
----------
1.04719755

To get result in degree, (180 degree= pi redian)
SQL> select acos(.5)*180/3.1416 from dual;
ACOS(.5)*180/3.1416
-------------------
59.9998597


3)ASIN
ASIN returns the arc sine of n. It behaves just like ACOS. The argument n must be in the range of -1 to 1, and ASIN returns a value in the range of -pi/2 to pi/2, expressed in radians.
Example:
To get arc sine value of .5 in radians,
SQL> SELECT ASIN(.5) FROM DUAL;
ASIN(.5)
----------
.523598776

To get arc sine value of .5 in degrees,

SQL> SELECT ASIN(.5)*180/3.1416 FROM DUAL;
ASIN(.5)*180/3.1416
-------------------
29.9999298

4)ATAN:
ATAN returns the arc tangent of n. It behaves just like ASIN, ACOS. The argument passed to this function can be in an unbounded range and returns a value in the range of -pi/2 to pi/2, expressed in radians.

To get arc tangent of 1 in radians,
SQL> SELECT ATAN(1) FROM DUAL;
ATAN(1)
----------
.785398163
To get arc tangent of value .5 in degrees,
SQL> SELECT ATAN(1) *180/3.1416 FROM DUAL;
ATAN(1)*180/3.1416
------------------
44.9998948

5)ATAN2:
This functions takes two arguments and return arc tangent of two arguments. The argument can be passed as ATAN2(n1,n2) or ATAN2(n1/n2) and both are same. The argument n1 can be in an unbounded range and this function returns a value in the range of -pi to pi, depending on the signs of n1 and n2, expressed in radians.

Example:
SQL> SELECT ATAN2(.2,.1) FROM DUAL;
ATAN2(.2,.1)
------------
1.10714872

6)BITAND:
BITAND function take two integer arguments and do an AND operation between them. Suppose if we want AND operation between 10 and 7 then it AND bit by bit which is
1010(10) and
0111(7) and result is

0010 (2)
SQL> SELECT BITAND(10,7) FROM DUAL;
BITAND(10,7)
------------
2

For 1(001) and 7(111) the result is 1 (001)
SQL> SELECT BITAND(1,7) FROM DUAL;
BITAND(1,7)
-----------
1

7)CEIL

CEIL returns smallest integer greater than or equal to the argument passed in it.
SQL> SELECT CEIL(1.8) FROM DUAL;
CEIL(1.8)
----------
2

SQL> SELECT CEIL(1.2) FROM DUAL;

CEIL(1.2)
----------
2
Since the smallest greater integer than 1.2 is 2.
SQL> SELECT CEIL(1.00) FROM DUAL;
CEIL(1.00)
----------
1


8)COS
The function COS takes single argument in radians in return consine of the value.
To get consine value of 60 degree,
SQL> SELECT COS(60*3.14159265359/180) FROM DUAL;
COS(60*3.14159265359/180)
-------------------------
.5

9)COSH
The COSH function takes a single numeric argument and returns the hyperbolic cosine of that value.
SQL> SELECT COSH(2) from dual;
COSH(2)
----------
3.76219569

No comments:

Post a Comment