The Basics of BINARY_FLOAT & BINARY_DOUBLE

Summary: in this tutorial, you will learn about the floating-point data types including BINARY_FLOAT and BINARY_DOUBLE.

Oracle 10g introduces two new floating point data types BINARY_FLOAT and BINARY_DOUBLE that allow you to store floating-point numbers in your table columns.

The floating-point numbers do not have the same precision as the NUMBER values, but they have a better performance for numerical computations. Because of this, the floating-point numbers are suitable for the scientific calculations but not suitable for financial calculations.

BINARY_FLOAT

  • IEEE 32 bit floating-point values
  • Range of +/3.4E+38
  • Precision of 6-7 digits
  • Require 4 bytes.

BINARY_DOUBLE

  • IEEE 64 bit floating-point value
  • Range of +/1.7E+308
  • Precision of 15 digits
  • Requires 8 bytes.

Oracle binary floating-point numbers support the special values Infinity and NaN (which stands for Not a Number) as follows:

Value BINARY_FLOAT BINARY_DOUBLE
Maximum positive finite value3.40282E+38F1.79769313486231E+308
Minimum positive finite value1.17549E-38F2.22507485850720E-308

To specify floating-point number literals, you add the suffix f for single precision and d double precision, as shown below:

SELECT 10.2d, 32.7f FROM dual;
Code language: SQL (Structured Query Language) (sql)

Oracle FLOAT vs. BINARY_FLOAT & BINARY_DOUBLE

The following are the major differences between FLOAT data type and floating-point data type:

  • The floating-point data types take advantage of hardware acceleration, therefore, they have better performance for numerical computations.
  • The floating-point data types can store smaller / larger numbers than FLOAT type.
  • The floating-point data types store only approximate values, while the FLOAT data type stores exact values.

In this tutorial, you have learned about the Oracle floating-point data types including BINARY_FLOAT and BINARY_DOUBLE.

Was this tutorial helpful?