Oracle Database - Floating-Point Number Datatype (BINARY_FLOAT, BINARY_DOUBLE)

> Database > Oracle Database

1 - About

Oracle provides two special datatype to store floating-point data:

Datatype Storage Format
BINARY_FLOAT single precision (32 bit) IEEE 754
BINARY_DOUBLE double precision (64-bit) IEEE 754
Advertising

3 - Comparison with the NUMBER datatype

Compared to the Oracle NUMBER data type, arithmetic operations on floating-point data are usually faster for BINARY_FLOAT and BINARY_DOUBLE. Also, high-precision values require less space when stored as BINARY_FLOAT and BINARY_DOUBLE.

A scale value is not applicable to floating-point numbers, because the number of digits that can appear after the decimal point is not restricted.

Binary floating-point numbers differ from NUMBER in the way the values are stored internally by Oracle Database. Values are stored using decimal precision for NUMBER. All literals that are within the range and precision supported by NUMBER are stored exactly as NUMBER. Literals are stored exactly because literals are expressed using decimal precision (the digits 0 through 9). Binary floating-point numbers are stored using binary precision (the digits 0 and 1). Such a storage scheme cannot represent all values using decimal precision exactly. Frequently, the error that occurs when converting a value from decimal to binary precision is undone when the value is converted back from binary to decimal precision. The literal 0.1 is such an example.

4 - BINARY datatype

4.1 - BINARY_FLOAT

BINARY_FLOAT is a 32-bit, single-precision floating-point number data type. Each BINARY_FLOAT value requires 5 bytes, including a length byte.

4.2 - BINARY_DOUBLE

BINARY_DOUBLE is a 64-bit, double-precision floating-point number data type. Each BINARY_DOUBLE value requires 9 bytes, including a length byte.

In a NUMBER column, floating point numbers have decimal precision. In a BINARY_FLOAT or BINARY_DOUBLE column, floating-point numbers have binary precision. The binary floating-point numbers support the special values infinity and NaN (not a number).

You can specify floating-point numbers within the limits listed in Table: Floating Point Number Limits.

5 - Floating Point Number Limits

Value Binary-Float Binary-Double
Maximum positive finite value 3.40282E+38F 1.79769313486231E+308
Minimum positive finite value 1.17549E-38F 2.22507485850720E-308
Advertising

6 - Documentation / Reference

  • SQL Developer Help
db/oracle/floating_point.txt · Last modified: 2017/09/13 16:04 by gerardnico