Comparison between the round () function and trunc () function in Oracle

Source: Internet
Author: User
The comparison between the round () function and trunc () function in Oracle is very practical.

The comparison between the round () function and trunc () function in Oracle is very practical.

In Oracle, the round () function is very useful compared with the trunc () function.

Round (x [, y])

[Function] returns the rounded value.

[Parameter] x, y, numeric expression. If y is not an integer, the y integer is truncated. If y is greater than 0, the rounding is y decimal, if y is less than 0, it is rounded to the y place to the left of the decimal point.

Return number

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

Return Value: 5555.67, 5600,555 6

[Close] trunc (x [, y]) returns the truncated value, which is used in the same way as round (x [, y]), but is not rounded down.

Trunc (x [, y])

[Function] returns the value after x is truncated by y.

[Parameter] x, y, numeric expression. If y is not an integer, the y integer is truncated. If y is greater than 0, the y decimal is truncated, if y is less than 0, the decimal point is truncated to the y-th place on the left. Other data before the decimal point is represented by 0.

Return number

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

Return Value: 5555.66 5500 5555

[Close] round (x [, y]) returns the value after the truncation. The usage is the same as that of trunc (x [, y]), but only rounding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.