# 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>`&#x20;

| Argument                              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>\<Variable><br>(Required)</p>      | Provide the variable whose data type needs to be changed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| <p>\<typecast type><br>(Required)</p> | <p>Provide the target data type to which the variable should be converted.</p><p>Supported data types are:</p><ul><li><strong>Int (Integer)</strong>: 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).</li><li><strong>Float</strong>: 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).</li><li><strong>Double</strong>: 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).</li><li><strong>String</strong>: values of string variables may include numbers, letters, or symbols. It used to convert date type to string.</li></ul> |

**Output Value**: `<Dynamic Variable>;<Dynamic Variable>(Optional)`

| Argument                                     | Description                                                        |
| -------------------------------------------- | ------------------------------------------------------------------ |
| <p>\<Dynamic Variable></p><p>(Required)</p>  | This dynamic variable stores the value or string after conversion. |
| <p>\<Dynamic Variable></p><p>(Optional) </p> | 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.

<figure><img src="/files/f6YyobT8EeU3l9T8iGI8" alt=""><figcaption></figcaption></figure>

#### **knowledge Bites:**&#x20;

Here are some examples of different string scenarios:

<table><thead><tr><th width="208.79998779296875">String</th><th width="285.800048828125">Input Value</th><th>Result </th></tr></thead><tbody><tr><td>float/double to int</td><td><p><strong>float to int:</strong> 34.56;int </p><p>                   <strong>OR</strong></p><p><strong>double to int:</strong> 34.56333333;int </p></td><td>34</td></tr><tr><td>int/double to float</td><td><strong>int to float:</strong> 34;float<br>                   <strong>OR</strong><br><strong>double to float:</strong> 34.563333334545565434;float</td><td><strong>int to float:</strong> 34.0<br>          <strong>OR</strong><br><strong>double to float:</strong> 34.5633333345455</td></tr><tr><td>int/float to double</td><td><strong>int to float:</strong> 89;float<br>                    <strong>OR</strong><br><strong>float to double:</strong> 98.4443;double</td><td><strong>int to float:</strong>89.0<br>            <strong>OR</strong> <br><strong>float to double:</strong> 98.4443</td></tr><tr><td>int/float/double to string</td><td><strong>int to string:</strong> 89;string<br>                    <strong>OR</strong><br><strong>float to string:</strong> 98.4443;string<br>                   <strong>OR</strong><br><strong>double to string:</strong> 435.554433;string</td><td><strong>int to string:</strong> 89<br>                    <strong>OR</strong><br><strong>float to string:</strong> 98.4443<br>                   <strong>OR</strong><br><strong>double to string:</strong> 435.554433</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.avoautomation.com/avo-assure/actions/generic/string-operations/type-cast.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
