---

slug: /floating-point-type
---

# Floating-point types

Floating-point types are fixed-length, non-precise numeric types. The value range and precision depend on the type length, precision, and scale, and whether the type is unsigned.

Precision and scale represent the maximum number of significant digits in decimal and the maximum number of significant digits in the fractional part, respectively. The maximum number of significant digits in the integer part is equal to the precision minus the scale. The maximum value of precision is 255 (scale can only be 0), and the maximum value of scale is 30.

  :::info

  The precision of floating-point types is only the theoretical value specified by the IEEE standard. In practice, it may vary slightly due to hardware or operating system limitations.

  :::

The following table shows the storage length and value range of floating-point types when precision and scale are not specified.

|    Type    | Length (bytes) |                                                       Value range                                                       |  Precision  |
|----------|--------|----------------------------------------------------------------------------------------------------------------|------|
| `FLOAT`  | 4      | \[-3.402823466E+38, -1.175494351E-38\], 0, and \[1.175494351E-38,3.402823466E+38\]                                 | 7 digits  |
| `DOUBLE` | 8      | \[-1.7976931348623157E+308, -2.2250738585072014E-308\], 0, and \[2.2250738585072014E-308,1.7976931348623157E+308\] | 15 digits |

If precision and scale are specified, the value range is determined in the same way as for fixed-point types.

## FLOAT

`FLOAT` is used to represent a small (single-precision) floating-point number. The syntax is as follows:

```sql
FLOAT[(M,D)] [UNSIGNED] [ZEROFILL]
```

`M` is the total number of digits that can be stored, and `D` is the number of digits after the decimal point. If `M` and `D` are omitted, the value is stored within the hardware's allowed limits. Single-precision floating-point numbers are accurate to about 7 decimal places.

If you specify `ZEROFILL` for a numeric column, seekdb automatically adds the `UNSIGNED` attribute to the column. If `UNSIGNED` is specified, negative values are not allowed.

  :::info

  `FLOAT(M,D)` is an outdated syntax and is not recommended for use.

  :::

`FLOAT` also supports the following syntax:

```sql
FLOAT(p) [UNSIGNED] [ZEROFILL]
```

`p` represents the precision in bits, but it is only used to determine whether the result data type is `FLOAT` or `DOUBLE`. If `p` is between 0 and 24, the data type becomes `FLOAT` without `M` or `D` values. If `p` is between 25 and 53, the data type becomes `DOUBLE` without `M` or `D` values. The value range of the result column is the same as that of the single-precision `FLOAT` or double-precision `DOUBLE` data types described earlier.

## DOUBLE

`DOUBLE` is used to represent a normal-sized (double-precision) floating-point number. The syntax is as follows:

```sql
DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL]
```

`M` is the total number of digits that can be stored, and `D` is the number of digits after the decimal point. If `M` and `D` are omitted, the value is stored within the hardware's allowed limits. Double-precision floating-point numbers are accurate to about 15 decimal places.

If you specify `ZEROFILL` for a numeric column, seekdb automatically adds the `UNSIGNED` attribute to the column. If `UNSIGNED` is specified, negative values are not allowed.

  :::info

  DOUBLE[(M,D)] is an outdated syntax from MySQL and is not recommended for use. If you need precise queries, it is recommended to use the DECIMAL type.

  :::

## DOUBLE PRECISION

`DOUBLE PRECISION` is a synonym for `DOUBLE`. The syntax is as follows:

```sql
DOUBLE PRECISION[(M,D)] [UNSIGNED] [ZEROFILL], REAL[(M,D)] [UNSIGNED] [ZEROFILL]
```

:::info

Binary floating-point numbers do not currently support special values such as `infinity` and `NaN`.

:::