Type Cast
This is a pre-built Action located under the @Generic Element. The functionality of this Action in Avo Assure is to convert the format or data type of a given variable into another type. The converted value is stored in a dynamic variable.
Syntax
Input Value: <Variable>;<typecast type>
<Variable> (Required)
Provide the variable whose data type needs to be changed.
<typecast type> (Required)
Provide the target data type to which the variable should be converted.
Supported data types are:
Int (Integer): It is used to store numbers without any decimal or fractional part. It used to convert from another type to integer type (double to int, float to int).
Float: The float is used to convert numbers into decimal point. It used to convert from another type to float type (double to float, int to float).
Double: A double variable that stores numeric values with decimal points, such as floating-point numbers. It used to convert from another type to integer (int to double, float to double).
String: values of string variables may include numbers, letters, or symbols. It used to convert date type to string.
Output Value: <Dynamic Variable>;<Dynamic Variable>(Optional)
<Dynamic Variable>
(Required)
This dynamic variable stores the value or string after conversion.
<Dynamic Variable>
(Optional)
This dynamic variable stores the status as True or False.
Example: Type Casting a Value to Float
In this example, we explain how to convert a value from one data type to another.
Action: Type Cast
Input Value: 98;float
The first argument (98) specifies the original value.
The second argument (float) specifies the target data type for conversion.
Output Value: {Type Casted value}
The converted value (98.0) is stored in this {Type Casted value} dynamic variable.
If the second output variable is defined, it stores the operation status with the following possible values:
True: If the type casting is successful.
False: If the conversion fails due to an invalid data type or incompatible value.
Logical Explanation: The Type Cast action fetches the value from the Input Value column (98;float) and converts it to the specified data type (float). After conversion, it stores the result (98.0) in the {Type Casted value} variable.

knowledge Bites:
Here are some examples of different string scenarios:
float/double to int
float to int: 34.56;int
OR
double to int: 34.56333333;int
34
int/double to float
int to float: 34;float OR double to float: 34.563333334545565434;float
int to float: 34.0 OR double to float: 34.5633333345455
int/float to double
int to float: 89;float OR float to double: 98.4443;double
int to float:89.0 OR float to double: 98.4443
int/float/double to string
int to string: 89;string OR float to string: 98.4443;string OR double to string: 435.554433;string
int to string: 89 OR float to string: 98.4443 OR double to string: 435.554433
Last updated
Was this helpful?