Varun Rao
Varun Rao

Reputation: 801

What is the meaning of <number>d or <number>f in oracle?

Here is the normal execution to select 100 from the dual table:

SQL> select 100 from dual;

       100
----------
       100

Here is the same execution adding 'a' to the number 100 which just sets the column name. The result will be same for any other alphabets except d and f.

SQL> select 100a from dual;

         A
----------
       100

Here is the same execution adding 'd' and 'f' to the number 100

SQL> select 100d from dual;

      100D
----------
  1.0E+002

SQL> select 100f from dual;

      100F
----------
  1.0E+002

Where is it useful? What does it mean?

Upvotes: 2

Views: 594

Answers (2)

Thomas G
Thomas G

Reputation: 10216

d and f are there to implicitly declare the number as a floating-point.

1.0E+002 is the scientific notation for 100

100a is just interpreted by oracle as number value 100 aliased a.


Official doc NUMBER and Floating-Point Literals

enter image description here

f or F indicates that the number is a 32-bit binary floating point number (of type BINARY_FLOAT).

d or D indicates that the number is a 64-bit binary floating point number (of type BINARY_DOUBLE)


An example of this behavior can be found in the ROUND() function doc

The following examples illustrate the difference between rounding NUMBER and floating-point number values. NUMBER values are rounded up (for positive values), whereas floating-point numbers are rounded toward the nearest even value:

SELECT ROUND(1.5), ROUND(2.5) FROM DUAL;

ROUND(1.5) ROUND(2.5)
---------- ----------
         2          3

SELECT ROUND(1.5f), ROUND(2.5f) FROM DUAL;

ROUND(1.5F) ROUND(2.5F)
----------- -----------
   2.0E+000    2.0E+000

Upvotes: 4

Roboprog
Roboprog

Reputation: 3144

Just a guess: the "f"/"F" suffix means floating point (thus, the scientific notation with mantissa and exponent).

"d"/"D" would perhaps be decimal??? (fixed precision decimal)

Google for Oracle Numeric Types, maybe :-(

Upvotes: -2

Related Questions