Sunday, July 20, 2008

Numeric REMAINDER ROUND SIGN SIN SINH SQRT TAN TANH TRUNC function

1)REMAINDER
The function REMAINDER holds the syntax REMAINDER(n2,n1) and returns the remainder of n2 divided by n1. This function is similar to MOD function except that MOD uses FLOOR in its formula, whereas REMAINDER uses ROUND.

Example:
SQL> SELECT REMAINDER(11,3) FROM DUAL;


REMAINDER(11,3)
---------------
-1

SQL> SELECT MOD(11,3) FROM DUAL;
MOD(11,3)
----------
2

2)ROUND (number)
The function ROUND has the syntax ROUND({n}[,integer]).
It returns n rounded to integer places to the right of the decimal point. If you omit integer, then n is rounded to 0 places. The argument integer can be negative to round off digits left of the decimal point.

Example:SQL> SELECT ROUND(11.283,1) FROM DUAL;

ROUND(11.283,1)
---------------
11.3

SQL> SELECT ROUND(11.283,-1)FROM DUAL;
ROUND(11.283,-1)
----------------
10

SQL> SELECT ROUND(11.283)FROM DUAL;
ROUND(11.283)
-------------
11

3)SIGN
The SIGN function returns the sign of a numeric datatype or datatype that can be implicitly converted to numeric datatype.
In case of numeric datatype,
If value <0 argument="0">0 then SIGN function returns 1.
In case of binary float or binary double it returns -1 if n<0>=0 or n=NaN

SQL> SELECT SIGN(0f) FROM DUAL;

SIGN(0F)
----------
1

As 0f is float so SIGN returns 1.
SQL> SELECT SIGN(-11) FROM DUAL;
SIGN(-11)
----------
-1

SQL> SELECT SIGN(0) FROM DUAL;
SIGN(0)
----------
0

4)SIN
The function SIN takes a value in radians and returns the sine value of the argument.
To get SIN value of 30 degree,
SQL> SELECT SIN(30 * 3.14159265359/180) FROM DUAL;
SIN(30*3.14159265359/180)
-------------------------
.5

5)SINH
SINH returns the hyperbolic sine of n.
SQL> SELECT SINH(2) FROM DUAL;
SINH(2)
----------
3.62686041

6)SQRT
SQRT returns the square root of n.
SQL> SELECT SQRT(256) FROM DUAL;
SQRT(256)
----------
16

7)TAN
TAN returns the tangent of n where n is expressed in radians.
To get tangent of 45 degree,
SQL> SELECT TAN(45 * 3.14159265359/180) FROM DUAL;
TAN(45*3.14159265359/180)
-------------------------
1
8)TANH
TANH returns the hyperbolic tangent of n.
Example:
SQL> SELECT TANH(1) FROM DUAL;
TANH(1)
----------
.761594156
9)TRUNC (number)
TRUNC (number) holds the syntax TRUNC({n2}[,n1]) where {} indicates mandatory option and [] indicate optional option.

It returns n1 truncated to n2 decimal places. If n2 is omitted, then n1 is truncated to 0 places. n2 can be negative to truncate (make zero) n2 digits left of the decimal point.

Example:SQL> SELECT TRUNC(13.59,1) FROM DUAL;
TRUNC(13.59,1)
--------------
13.5

SQL> SELECT TRUNC(13.59,-1) FROM DUAL;
TRUNC(13.59,-1)
---------------
10

SQL> SELECT TRUNC(13.59,0) FROM DUAL;
TRUNC(13.59,0)
--------------
13

No comments:

Post a Comment