Real Numbers
On this page
Data Type |
Size |
Size (Not Null) |
Synonyms |
Precision |
Syntax |
---|---|---|---|---|---|
FLOAT |
4 bytes |
4 bytes |
23 bits |
FLOAT |
|
DOUBLE |
8 bytes |
8 bytes |
REAL |
53 bits |
DOUBLE |
DECIMAL |
see note |
see note |
DEC, FIXED, NUMERIC |
65 digits |
|
Note
The space consumed by the DECIMAL data type varies with the precision and scale arguments.
For optimal query performance, use 18 total digits or less for the DECIMAL or NUMERIC data types.
The formula for the number of bytes used to store a decimal value is (ceil((P - S) / 9) + ceil(S / 9)) * 4.
Note
For FLOAT and DOUBLE, precision refers to the number of bits in the significand.
Working with Floats and Doubles
FLOAT
and DOUBLE
represent approximate values and SingleStore follows IEEE 754 standards (see FLOAT
| see DOUBLE
) for floating point numbers.
The precision listed in the Real Numbers table refers to the number of bits used to store the significand.FLOAT
, 23 bits is about 6 digits.DOUBLE
, which stores up to 17 digits.
Numbers exceeding the precision of the data type are rounded according to the IEEE 754 standard when entered.
CREATE TABLE rn_t (id float);INSERT INTO rn_t VALUES (1234567);INSERT INTO rn_t VALUES (123.4567);
SELECT * FROM rn_t;
+---------+
| id |
+---------+
| 123456 |
| 123.457 |
+---------+
Warning
Avoid using the =
or !=
comparison operators on FLOAT
columns in WHERE
clauses due to the potential inaccuracy of the FLOAT
data type.>
or <
comparison operators on FLOAT
columns.
Last modified: March 8, 2024