int16
- Details
- Last Updated on Tuesday, 15 January 2013 16:48
syntax
- int16(a)
definition
int16(a) results in a 16 bits signed integer item casted from item a. The function results in:
- for integer data items, the integer value is interpreted as int16 value, if the value exceeds the maximum value for int16 value types, the result is null;
- for float32/64 data items the value before the decimal point is used (so 1.9 will be rounded off to 1 and 2.0 to 2). If the value exceeds the maximum value for int16 value types, the result is null;
- for boolean data items, 1 for True values and 0 for False values;
- for string data items, if the value starts with an allowed numeric value for the value type, this value is casted to a int16 value type. Other characters found after the numeric values are neglected. If the string does not start with an allowed numeric value for the value type, the result value is null.
- for units, a 16 bits signed integer variant of the casted unit.
description
int16 is used as a function to cast units or data items to the value type with the similar name. The allowed range of values for the int16 value type can be found in the value types table.
applies to
Data items and units with value types:
- group: Numeric
- uint2
- uint4
- bool
- string
since version
5.15
example
1. attribute<int16> int16A (ADomain): expr = "int16(A)";
2. attribute<int16> int16B (ADomain): expr = "int16(B)";
| A(float32) | B(string) | int16A | int16B | |
| 0 | 'Hello' | 0 | null | |
| 1 | 'Test' | 1 | null | |
| 1000000 | null | null | null | |
| -2.5 | 'Two words' | -2 | null | |
| 99.9 | '88a' | 99 | 88 |
Table ADomain, nr of rows = 5