Oracle decimal format up-down rounding

Source: Internet
Author: User


Rounding (rounding down):
Select Floor (5.534) from dual;
Select Trunc (5.534) from dual;
Both of the above can be rounded down to the number 5.534, and the result is 5.


If you want to take the whole up and get the result of 6, you should use Ceil
Select Ceil (5.534) from dual;


Rounded:
SELECT round (5.534) from dual;
SELECT round (5.534,0) from dual;
SELECT round (5.534,1) from dual;
SELECT round (5.534,2) from dual;
The results were 6, 6, 5.5, 5.53, respectively.


Keep n decimal places (not rounded):
Select Trunc (5.534,0) from dual;
Select Trunc (5.534,1) from dual;
Select Trunc (5.534,2) from dual;
The result is 5,5.5,5.53, which retains 0 decimal places as the equivalent of direct rounding.


Number formatting:
Select To_char (12345.123, ' 99999999.9999 ') from dual;
Result is 12345.123

Select To_char (12345.123, ' 99999999.9900 ') from dual;
After the third fourth of the decimal is insufficient to fill 0, the result is 12345.1230

Select To_char (0.123, ' 99999999.9900 ') from dual;
Select To_char (0.123, ' 99999990.9900 ') from dual;
The results were. 123, 0.123

Oracle decimal format up-down 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.