Home > Database > Oracle > How to add two decimal points to an integer in Oracle?

How to add two decimal points to an integer in Oracle?

下次还敢
Release: 2024-05-02 23:42:52
Original
652 people have browsed it

There are two ways to represent integers with two decimal points in Oracle: scientific notation (such as 100 * 10^-2 = 0.01) and the TO_CHAR function (such as TO_CHAR(100, 'fm9999999999990.99') = 0.01).

How to add two decimal points to an integer in Oracle?

Integer complement two decimal point representation in Oracle

In Oracle, you can use scientific notation or TO_CHAR Function to complete an integer to two decimal places.

Scientific notation

Scientific notation uses exponents to indicate the position of the decimal point. For an integer n, its scientific notation complemented with two decimal points is expressed as:

<code>n * 10^-2</code>
Copy after login

For example, the integer 100 complemented with two decimal points can be expressed using the following scientific notation:

<code>100 * 10^-2 = 0.01</code>
Copy after login

TO_CHAR function

TO_CHAR function can convert numbers into strings in a specified format. For an integer n, the TO_CHAR function that complements two decimal points is expressed as:

<code>TO_CHAR(n, 'fm9999999999990.99')</code>
Copy after login

where, 'fm9999999999990.99' specifies the number format, where:

  • 'f' means Floating point number
  • 'm' means expressed in scientific notation
  • '9' means digit
  • '.' means decimal point
  • '0' means Zeros to the left of the decimal point

For example, to complement the integer 100 with two decimal points, you can use the following TO_CHAR function to express:

<code>TO_CHAR(100, 'fm9999999999990.99') = 0.01</code>
Copy after login

The above is the detailed content of How to add two decimal points to an integer in Oracle?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template