Quote:
What's the code PL/sql for find the part integer end decimal of number? |
In Oracle8i use TRUNC function to get the integer part:
TRUNC( a )
eg.:
TRUNC( +2.5 ) == +2
TRUNC( -2.5 ) == -2
and combine it with oryginal number to get fractional part:
a - TRUNC( a )
eg.:
(+2.5) - TRUNC( +2.5 ) == 2.5 - 2 = 0.5
(-2.5) - TRUNC( -2.5 ) == -2.5 + 2 = -0.5
or create new function:
CREATE FUNCTION FRACT( num IN NUMBER ) RETURN NUMBER DETERMINISTIC AS
BEGIN
RETURN num - TRUNC( num );
END;
FRACT( +2.5 ) == +0.5
FRACT( -2.5 ) == -0.5
Newer versions of Oracle can allready have function acting like above FRACT.
Hilarion