Gladius supports all of the standard SQL numeric data types. These types include the exact
numeric data types (INTEGER, SMALLINT, DECIMAL, and NUMERIC), as well as the
approximate numeric data types (FLOAT, REAL, and DOUBLE PRECISION).
The following table shows the mapped storage type and range for each of the numeric types.
|
Alias
|
Storage type
|
Operative range**
|
|
int*
|
INTEGER
|
0 to 4294967295
or
-2147483648 to 2147483648
|
|
integer
|
|
smallint
|
|
tinyint*
|
|
bigint
|
|
numeric
|
DOUBLE
|
maximum ~1.8e308
|
|
decimal
|
|
float
|
|
double*
|
|
real
|
* = not in SQL92 standard
** = suggested operative ranges
Operative ranges
No range checking is performed on parsed numeric values; the real allowed range is platform
dependant (the above limits are relative to a standard 32bit architecture) and it is theorically
possible to use wider ranges. Outside the suggested operative ranges behaviour will be
platform dependant. If an integer overflows the host architecture maximum integer value a
floating point will instead be used to store its value; overflowing even the floating-point
maximum value results in undefined behaviour.
Display width
The display width of an integer value, usually specified in parentheses following the base
keyword for the type (example: INT(10)), are not considered at all. Gladius will simply ignore
their declarations.
Floating point numbers
The floating point data types (mapped to DOUBLE) are used to represent approximate
numeric data values. An optional specification of the precision (but not the range of the
exponent) in bits following the keyword FLOAT in parentheses is allowed. Such precision
value is used to validate the parsed numerical value.
For maximum portability, code requiring storage of approximate numeric data values should
use FLOAT or DOUBLE* with no specification of precision or number of digits.
* = DOUBLE stands for the standard DOUBLE PRECISION data type
The DECIMAL and NUMERIC data types are used to store exact numeric data values. Both
types are implemented as DECIMAL, these types are used to store values for which it is
important to preserve exact precision but Gladius currently does not handle custom floating
point precision values and all floating point values will retain the same precision (see previous
table).