Number Functions
Number functions accept numeric input and return numeric values. This function deals with numeric functions
ABS
Syntax
ABS (n)
Return the absolute value of n
Example
SELECT ABS (-15) "Absolute" FROM DUAL Absolute
--------
15
FLOOR
Syntax
FLOOR(n)
It will Return the largest integer equal to or less than n.
Example
SELECT FLOOR(15.7) "Floor" FROM DUAL Floor
-----
15
CEIL
Syntax
CEIL(n)
It will Return the smallest integer greater than or equal to n.
Example
SELECT CEIL(15.7) "Ceiling" FROM DUAL Ceiling
-------
16
EXP
Syntax
EXP(n)
It will Return e raised to the nth power where the value of e is = 2.71828183...
Example
SELECT EXP(4) "e to the 4th power" FROM DUAL# for selecting 4th power of e from dual table#
e to the 4th power
------------------
54.59815
LN
Syntax
LN(n)
It will Return the natural logarithm of n where the n is greater than 0.
Example
SELECT LN(95) "Natural log of 95" FROM DUAL
Natural log of 95
-----------------
4.5538769
LOG
Syntax
LOG(m,n)
It will return the logarithm, base m, of n. Base m can be any positive number other than 0 or 1 and n can be any positive number.
Example
SELECT LOG(10,100) "Log base 10 of 100" FROM DUAL
Log base 10 of 100
------------------
2
MOD
Syntax
MOD(m,n)
It will Return the remainder of m divided by n it will Returns m if n is 0.
Example
SELECT MOD(11,4) "Modulus" FROM DUAL
Modulus
-------
3
POWER
Syntax
POWER(m,n)
It will Return m raised with the nth power. The exponent n and base m the can be any numbers but if m value is negative, n value must be an integer.
Example
SELECT POWER(3,2) "Raised" FROM DUAL Raised
------
9
ROUND
Syntax
ROUND(n[,m])
It will Returns n rounded to m places right of the decimal point if m is omitted and n is rounded to 0 places. The m can be negative to round off digits left of the decimal point. An m must be an integer.
Example
SELECT ROUND(15.193,1) "Round" FROM DUAL Round
-----
15.2
SIGN
Syntax
SIGN(n)
If n<0 then the function returns -1; if n=0 then the function returns 0; if n>0, the function returns 1.
Example
SELECT SIGN(-15) "Sign" FROM DUAL Sign
----
-1
SQRT
Syntax
SQRT(n)
It will return square root of n. The n value cannot be negative. SQRT will returns a "real" result.
Example
SELECT SQRT(26) "Square root" FROM DUAL # for calculating a square root of 26#
Square root
----------
5.0990195
TRUNC
Syntax
TRUNC(n[,m])
It will return n truncated to m decimal places if m is omitted then n is truncated to 0 places. m can be negative to truncate (make zero) m digits left of the decimal point.
Example
SELECT TRUNC(15.79,1) "Truncate" FROM DUAL
Truncate
--------
15.7
SELECT TRUNC(15.79,-1) "Truncate" FROM DUAL
Truncate
--------
10