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?

下次还敢
下次还敢Original
2024-05-02 23:42:52655browse

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>

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>

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>

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>

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!

Statement:
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
Previous article:How to use case in oracleNext article:How to use case in oracle