Versions available for this page: CUBRID 8.3.1 | CUBRID 8.4.0 | CUBRID 8.4.1 | CUBRID 8.4.3 | CUBRID 9.0.0 |

CUBRID supports the following numeric data types to store integers or real numbers.

Type |
Bytes |
Mix |
Max |
Exact/approx. |
---|---|---|---|---|

SHORT |
2 |
-32,768 |
+32,767 |
exact numeric |

INT |
4 |
-2,147,483,648 |
+2,147,483,647 |
exact numeric |

BIGINT |
8 |
-9,223,372,036,854,775,808 |
+9,223,372,036,854,775,807 |
exact numeric |

NUMERIC |
16 |
precision p : 1 |
precision p : 38 scale s : 38 |
exact numeric |

FLOAT |
4 |
-3.402823466E+38 (ANSI/IEEE 754-1985 standard) |
+3.402823466E+38 |
approximate numeric |

DOUBLE |
8 |
-1.7976931348623157E+308 ANSI/IEEE 754-1985 standard) |
+1.7976931348623157E+308(ANSI/IEEE 754-1985 standard) |
approximate numeric |

MONETARY |
12 |
-3.402823466E+38 |
+3.402823466E+38 |
approximate numeric |

Numeric data types are divided into exact and approximate types. Exact numeric data types (SMALLINT, INT, BIGINT, NUMERIC) are used for numbers whose values must be precise and consistent, such as the numbers used in financial accounting. Note that even when the literal values are equal, approximate numeric data types (FLOAT, DOUBLE, MONETARY) can be interpreted differently depending on the system.

CUBRID does not support the UNSIGNED type for numeric data types.

Precision and Scale

The precision of numeric data types is defined as the number of significant digits. This applies to both exact and approximate numeric data types.

The scale represents the number of digits following the decimal point. It is significant only in exact numeric data types. Attributes declared as exact numeric data types always have fixed precision and scale. NUMERIC (or DECIMAL) data type always has at least one-digit precision, and the scale should be between 0 and the precision declared. Scale cannot be greater than precision. For INTEGER, SMALLINT, or BIGINT data types, the scale is 0 (i.e. no digits following the decimal point), and the precision is fixed by the system.

Numeric Literals

Special signs can be used to input numeric values. The plus sign (+) and minus sign (-) are used to represent positive and negative numbers respectively. You can also use scientific notations. In addition, you can use currency signs specified in the system to represent currency values. The maximum precision that can be expressed by a numeric literal is 255.

Numeric Coercions

All numeric data type values can be compared with each other. To do this, automatic coercion to the common numeric data type is performed. For explicit coercion, use the CAST operator. When different data types are sorted or calculated in a numerical expression, the system performs automatic coercion. For example, when adding a FLOAT attribute value to an INTEGER attribute value, the system automatically coerces the INTEGER value to the most approximate FLOAT value before it performs the addition operation.

Caution Earlier version than CUBRID 2008 R2.0, the input constant value exceeds INTEGER, it is handled as NUMERIC. However, 2008 R2.0 or later versions, it is handled as BIGINT.

Show Comments (0)