# The difference between Oracle round of and trunc of functions is introduced

- 2021-01-02 22:01:48
- OfStack

round(x[,y])

[Function] returns the value after rounding 4 into 5

[Parameter] x,y, numeric expression, if y is not an integer, intercept the y integer part, if y > 0 rounds 5 to the y digit, and if y is less than 0 rounds 5 to the y digit to the left.

[Return] number

[Example] select round(5555.6666,2.1),round(5555.6666,-2.6),round(5555.6666) from dual;

Return: 5555.67, 5600, 5556

[Close] trunc(x[,y]) returns the intercepted value, which is used in the same way as round(x[,y]), but not rounded into 5

trunc(x[,y])

[Function] Returns the intercepted value of x at the precision of y

[Parameter] x,y, numeric expression, if y is not an integer, intercept the part of y integer, if y > If y is less than 0, it intercepts the y digit to the left of the decimal point. The other data before the decimal is represented by 0.

[Return] number

[Example] select trunc(5555.66666,2.1),trunc(5555.66666,-2.6),trunc(5555.033333) from dual;

Return: 5555.66 5500 5555

[Close] round(x[,y]) returns the intercepted value, which is used in the same way as trunc(x[,y]), but with the rounding of 4 to 5

[Function] returns the value after rounding 4 into 5

[Parameter] x,y, numeric expression, if y is not an integer, intercept the y integer part, if y > 0 rounds 5 to the y digit, and if y is less than 0 rounds 5 to the y digit to the left.

[Return] number

[Example] select round(5555.6666,2.1),round(5555.6666,-2.6),round(5555.6666) from dual;

Return: 5555.67, 5600, 5556

[Close] trunc(x[,y]) returns the intercepted value, which is used in the same way as round(x[,y]), but not rounded into 5

trunc(x[,y])

[Function] Returns the intercepted value of x at the precision of y

[Parameter] x,y, numeric expression, if y is not an integer, intercept the part of y integer, if y > If y is less than 0, it intercepts the y digit to the left of the decimal point. The other data before the decimal is represented by 0.

[Return] number

[Example] select trunc(5555.66666,2.1),trunc(5555.66666,-2.6),trunc(5555.033333) from dual;

Return: 5555.66 5500 5555

[Close] round(x[,y]) returns the intercepted value, which is used in the same way as trunc(x[,y]), but with the rounding of 4 to 5