Non-integer Numbers
Floating-point and fixed-point numbers are used to specify non-integer numbers. Different floating point datatypes represent different precisions numbers.
DOUBLE
and are aliases.non_integer_floating_point_literal
is used for values ofFLOAT
,DOUBLE
andDOUBLE PRECISION
types.non_integer_fixed_point_literal
is used for values ofDECIMAL
type.
- Values of different floating-point and fixed-point datatypes are comparable and convertible to one another.
- Conversion from floating-point types into
DECIMAL
will raise an error for the special valuesNaN
, , and-Infinity
.
- Conversion from floating-point types into
- The ordering for special floating-point values is defined as (in ascending order):
-Infinity
, all negative values in order, all positive values in order,Infinity
, andNaN
.
You can do this as shown below.
cqlsh:example> CREATE TABLE sensor_data (sensor_id INT PRIMARY KEY, float_val FLOAT, dbl_val DOUBLE, dec_val DECIMAL);
cqlsh:example> UPDATE sensor_data SET float_val = 1, dbl_val = 1, dec_val = 1 WHERE sensor_id = 2;
sensor_id | float_val | dbl_val | dec_val
-----------+-----------+-----------+-------------
1 | 321.04568 | 321.04568 | 321.0456789