Floating-point numbers can have a decimal point anywhere from the first to the last digit, or can have no decimal point at all. You can choose to optionally use an exponent following the number to increase the range, for example, 1.666 e^-20^. Decimal places are not applicable to floating-point numbers, because the number of digits that can appear after the decimal point is not limited. Notice
Binary floating-point numbers differ from NUMBER in the way where the values are internally stored by ApsaraDB for OceanBase. All values of the NUMBER data type are exactly stored with decimal precision. Binary floating-point numbers are stored with binary precision by using the digits 0 and 1. Such a storage method cannot exactly represent all values that use decimal precision.
Syntax
ApsaraDB for OceanBase provides two numeric data types for floating-point numbers:
BINARY_FLOATis a 32-bit single-precision floating-point number data type. EachBINARY_FLOATvalue requires 4 bytes.BINARY_DOUBLEis a 64-bit double-precision floating-point number data type. EachBINARY_DOUBLEvalue requires 8 bytes. NoteIn a
NUMBERcolumn, floating-point numbers have decimal precision.In a
BINARY_FLOATorBINARY_DOUBLEcolumn, floating-point numbers have binary precision.The binary floating-point numbers do not support the special values
infinityandNaN(not a number).
Value range
You can specify floating-point numbers within the value range.
| 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 |
More information
IEEE754 conformance
- IEEE Standard 754-1985 (IEEE754)
The implementation of floating-point data types in ApsaraDB for OceanBase conforms substantially with the Institute of Electrical and Electronics Engineers (IEEE) Standard for Binary Floating-Point Arithmetic.
- The floating-point data types conform to
IEEE754in the following areas:
- The floating-point data types do not conform to IEEE754 in the following areas: