INT16
This function is used to cast data to the INT16
data type.
Syntax​
INT16 ( arg )
arg
The value to be cast. The value has to be of a Numeric or Date & Time data type category.
Return Value​
Returns the INT16
representation of the value provided.
Remarks​
- If the value falls outside of the
INT16
range, an overflow error is returned. - Date & Time values are first converted to their underlying unix representation before being converted.
- Conversions from floating point numbers floor the value.
Examples​
This returns the INT16
representation of -1. Without data type context, numeric values are interpreted
as their largest datatype. In this example, because -1 is signed it's interpreted as an INT64
.
SELECT INT16(-1);
Response:
INT16(-1) [INT16]
-1
If we operate on a values that exceeds the range of INT16
the query errors.
SELECT INT16(-32768);
Response:
The provided value overflows INT16