I got a book of oracle and reading functions round and trunc. They are given as round(14.236,2) This number is rounded to 14.24 but round(45.862,-1) is rounded as 50 (How it is so) Same as;;;;;;; trunc(45.862,0) This number is trunc to 45 but trunc(45.862,-1) is trunc to 40 (How it is so) plz help me , how it happens .........in - (minus) case
round (n,d) The round function rounds a number n to the specified decimal d. The decimal d can be positive, negative or zero. If the decimal is positive, then the number is rounded to that many decimal points. The number five rounds up. If d is zero, then the number is rounded to no decimal points. If d is negative, then the number will have no decimal points and it will be rounded to the d digits to the left of the decimal point. SELECT ROUND( 1234.345, 2), ROUND( 1234.345, 0), ROUND( 1234.345, -2) FROM dual; ROUND(1234.345,2) ROUND(1234.345,0) ROUND(1234.345,-2) ----------------- ----------------- ------------------ 1234.35 1234 1200 trunc (n,d) The trunc or truncate function simply drops the digits without rounding. The decimal d can again be positive, negative or zero. If the number truncated is five or higher, it is still dropped without rounding the next digit up. SELECT TRUNC( 1234.345, 2), TRUNC( 1234.345, 0), TRUNC( 1234.345, -2) FROM dual; TRUNC(1234.345,2) TRUNC(1234.345,0) TRUNC(1234.345,-2) ----------------- ----------------- ------------------ 1234.34 1234 1200