2. Language Elements : Expressions : Literals : Numeric Literals
 
Share this page                  
Numeric Literals
Numeric literals specify numeric values. There are three types of numeric literals:
Integer
Decimal
Floating point
A numeric literal can be assigned to any of the numeric data types or the money data type without using an explicit conversion function. The literal is automatically converted to the appropriate data type, if necessary.
By default, the period (.) is displayed to indicate the decimal point. This default can be changed by setting II_DECIMAL. For information about setting II_DECIMAL, see the Workbench User Guide.
Note:  If II_DECIMAL is set to comma, be sure that when SQL syntax requires a comma (such as a list of table columns or SQL functions with several parameters), that the comma is followed by a space. For example:
select col1, ifnull(col2, 0), left(col4, 22) from t1:
Integer Literals
Integer literals are specified by a sequence of 10 digits and an optional sign, in the following format:
[+|-] digit {digit} [e digit]
Integer literals are represented internally as an integer, smallint, or bigint depending on the value of the literal. If the literal is within the range -32,768 to +32,767, it is represented as a smallint. If its value is within the range -2,147,483,648 to +2,147,483,647 but outside the range of a smallint, it is represented as an integer. A literal in the range -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 is represented as a bigint. Values that exceed the range of integers are represented as decimals.
You can specify integers using a simplified scientific notation, similar to the way floating point values are specified. To specify an exponent, follow the integer value with the letter, e, and the value of the exponent. This notation is useful for specifying large values. For example, to specify 100,000 use the exponential notation as follows:
1e5
Decimal Literals
Decimal literals are specified as signed or unsigned numbers of 1 to 39 digits that include a decimal point. The precision of a decimal number is the total number of digits, including leading and trailing zeros. The scale of a decimal literal is the total number of digits to the right of the decimal point, including trailing zeros.
Decimal literals that exceed 39 digits are treated as floating point values.
Examples of decimal literals are:
3.
-10.
1234567890.12345
001.100
Floating Point Literals
A floating point literal must be specified using scientific notation. The format is:
[+|-] {digit} [.{digit}] e|E [+|-] {digit}
For example:
2.3e-02
At least one digit must be specified, either before or after the decimal point.