Calculate Field Operations
Calculate field operations use simple equations to do mathematical functions on one or more fields.
- DECIMAL
- INT8
- INT16
- INT32
- INT64
- UINT8
- UINT16
- UINT32
- UINT64
fieldA
,fieldB
,fieldC
— a field name with its MDC selectornumber
— a numeric constantThe data type used for a constant value is determined by its value using the following conventions:- If the value has a decimal ( ".") in it, then it is a DECIMAL type.
- If the value starts with a dash ("-"), then it is an INT64 type.
- If the value does not have a decimal or start with a dash, it is an UINT64 type.
op
— A mathematical operation ( +, -, *, /, %).opEqual
— A mathematical operation that takes one operand (+=, -=, *=, /=, %=).
fieldA op = number
fieldA op = fieldB
fieldA = number
fieldA = fieldB
fieldA = fieldB op number
-
fieldA = fieldB op fieldC
-
fieldA opEqual number
fieldA opEqual fieldB
- If the data types of the result field and the operand fields are the same, then the operation is executed using that data type.
- If the data type of the result field or the data type of any of the operand fields is DECIMAL, then all fields are converted to DECIMAL and the operation is executed in DECIMAL. If the data type of the result field is not a DECIMAL, the result from the operation is converted from a DECIMAL to its data type.
- If the data type of any of the operand fields is signed (INT8, INT16, INT32, INT64), then the operation is executed by converting the operand fields to INT64 values.
- For all other situations, the operation is executed by converting the operand fields to UINT64 values.
The following examples demonstrate how to use the
calculate_field
operation.
Data Type Conversions
When converting values from data type A to data type B, the maximum
and minimum values of data type B are considered. If the data type A value
exceeds the maximum value of data type B, then the maximum value of data type B
is used. If the data type A value is less than the minimum value of data type
B, then the minimum value of data type B is used. For example, if data type A
is an INT16 value of 32000 and data type B is an UINT8, data type B has a value
of 255 because that is the maximum value of a UINT8 data type.Data Type Maximum and Minimum Values
lists the
calculate_field
operation supported data types and
their maximum and minimum values.
Data Type | Minimum Value | Maximum Value |
---|---|---|
INT8 | -128 | 127 |
INT16 | -32768 | 32767 |
INT32 | -2147483648 | 2147483647 |
INT64 | -9223372036854775808 | 9223372036854775807 |
UINT8 | 0 | 255 |
UINT16 | 0 | 65535 |
UINT32 | 0 | 4294967295 |
UINT64 | 0 | 18446744073709551615 |
Make FieldA Equal to the Sum of FieldB and FieldC
SelectiveUpdate:DiameterGateway:Input:Element 6002:Operation 1:What operation do you want to perform?calculate_field
SelectiveUpdate:DiameterGateway:Input:Element 6002:Operation 1:CalculateField:What is the equation?main:Result.FieldDecimal = main:OperandA.FieldDecimal + main:OperandB.FieldInt8
Make FieldA Equal to the Difference of FieldB and a Constant
SelectiveUpdate:DiameterGateway:Input:Element 6130:Operation 4:What operation do you want to perform?calculate_field
SelectiveUpdate:DiameterGateway:Input:Element 6130:Operation 4:CalculateField:What is the equation?main:Result.FieldInt32 = main:OperandA.FieldInt16 - 4
Make FieldA Equal to FieldB
SelectiveUpdate:DiameterGateway:Input:Element 6426:Operation 1:What operation do you want to perform?calculate_field
SelectiveUpdate:DiameterGateway:Input:Element 6426:Operation 1:CalculateField:What is the equation?main:Result.FieldInt32 = main:OperandA.FieldInt8
Make a Field Equal to a Constant
SelectiveUpdate:DiameterGateway:Input:Element 6473:Operation 4:What operation do you want to perform?calculate_field
SelectiveUpdate:DiameterGateway:Input:Element 6473:Operation 4:CalculateField:What is the equation?main:Result.FieldInt32 = 2
Add 1 to FieldA
SelectiveUpdate:DiameterGateway:Input:Element 6180:Operation 4:What operation do you want to perform?calculate_field
SelectiveUpdate:DiameterGateway:Input:Element 6180:Operation 4:CalculateField:What is the equation?main:Result.FieldUInt32 +=
1
Make FieldA Equal to the Sum of FieldA and FieldB
SelectiveUpdate:DiameterGateway:Input:Element 6185:Operation 4:What operation do you want to perform?calculate_field
SelectiveUpdate:DiameterGateway:Input:Element 6185:Operation 4:CalculateField:What is the equation?main:Result.FieldUInt32 +=
main:A.FieldUInt16