---
title: Use the Rounding Function
slug: manufacturing-connect-edge/use-the-rounding-function
docTags: 
createdAt: 2024-05-24T20:16:07.916Z
---

You can use the Rounding processor to round off the collected data to the nearest decimal place.

# Understanding Rounding Methods

You have the following rounding options:

- **roundNearest:&#x20;**&#x54;his method returns a rounded value based on the number of decimal digits configured. For instance, if you set two decimal digits and the value is 1.5677, the rounded value will be 1.57.
- **roundUp:&#x20;**&#x41; method that rounds up the value to the specified number of decimal digits. For example, if you specify two decimal digits and the value is 1.3221, the rounded up value would be 1.33.
- **roundDown:&#x20;**&#x41; method that rounds down the value to the specified number of decimal digits. For example, if you specify two decimal digits and the value is 1.3221, the rounded value is 1.32.
- **roundEven:&#x20;**&#x54;his method rounds to the nearest even integer in cases of rounding ties (when both integers are equidistant, e.g. 1.5). In any other case, it acts as a round nearest function. If the value is 1.3221 and 1.5, the rounded even value is 1 and 2, respectively, as the nearest even integer.

# User Scenario

Review the following scenario for rounding off the tag values. Then, you will simulate data from a PLC and make the following rounding conversions.

Some of your manufacturing sites with multiple PLCs collect data with high precision. You can round off the collected data for easier aggregation, computation, visualization, comprehension, and communication.

# Step 1: Add a Device

Follow the steps to [Connect a Device](docId\:nm1lQfefyA-DSIfFitIty) and configure the following parameters:

- **Device Type**: Simulator
- **Driver Name**: Generator
- **Enable Alias Topics**: Select the checkbox.&#x20;

# Step 2: Add Tags

After connecting the device, add the following tags. See [Add a Tag](docId\:h5heqIcXrCY3NCH9KBg9I) to learn more. Each tag will represent one of the round function options noted above. 

## Tag 1: RoundNearest

- **Name**: Select **S - Random value generator**
- **Value Type**: Select **float64**
- **Polling Interval**: Enter **5**
- **Tag Name**: Enter **RoundNearest**
- **Min\_value**: Enter **1.523**
- **Max\_value**: Enter **1.523**

## Tag 2: RoundUp

- **Name**: Select **S - Random value generator**
- **Value Type**: Select **float64**
- **Polling Interval**: Enter **5**
- **Tag Name**: Enter **RoundUp**
- **Min\_value**: Enter **1.523**
- **Max\_value**: Enter **1.523**

## Tag 3: RoundDown

- **Name**: Select **S - Random value generator**
- **Value Type**: Select **float64** 
- **Polling Interval**: Enter **5**
- **Tag Name**: Enter **RoundDown**
- **Min\_value**: Enter **1.523**
- **Max\_value**: Enter **1.523**

## Tag 4: RoundEven

- **Name**: Select **S - Random value generator**
- **Value Type**: Select **float64**
- **Polling Interval**: Enter **5**
- **Tag Name**: Enter **RoundEven**
- **Min\_value**: Enter **1.523**
- **Max\_value**: Enter **1.523**

# Step 3: Create Analytics Flows

You can now create the analytics flows using data from the device and tags you previously created. 

**To create an analytics flow with the Rounding function:**

1. Navigate to **Analytics**.&#x20;
2. On the analytics canvas, click **Add processor**.&#x20;
   The *Create a processor&#x20;*&#x64;ialog displays.
   ![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/Qq52C-IDqas83XCZZIrtW_image.png "The Add processor option")
3. Select **DataHub Subscribe**.&#x20;
4. In the *Topic&#x20;*&#x66;ield, click the **Search&#x20;**&#x69;con, select the device you previously created, and then select the alias topic for the **RoundNearest** tag.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/ba4KySWrRukAfOQSXbAtn_image.png" size="80" width="1141" height="571" position="center" caption="Create a Processor dialog box" showCaption="true"}
5. Click **Save**.&#x20;
6. Click **Add processor** again and select **Rounding**.
   The following information describes this function:
   - For **Digits**, enter the number of digits for which you would like to round.
   - Entering `0` ignores all floating point values and gives the integer value.
   - For **Method**, select **roundNearest.**
7. Click **Save**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/TROl6p5VoKF4IHPsbIaP4_image.png" size="80" width="1134" height="664" position="center" caption="Rounding Pocessor dialog box" showCaption="true"}
8. Connect the two processors, select **Events**, and enter a definition of **roundnearest&#xA0;**&#x66;or the connection.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/GRZM8rgwHCwJ3kvE2xZ71_image.png" size="80" width="755" height="406" position="center" caption="Processor flow for roundnearest tag" showCaption="true"}
9. Repeat steps 2-8 for the round-up tag and configure the following:
   - In the *DataHub Subscribe* processor, select the alias topic for the **RoundUp&#x20;**&#x74;ag. 
   - In the *method dropdown*, select **roundUp.** 
   - When you connect the two processors, select **Events&#xA0;**&#x61;nd enter a definition of **roundup&#xA0;**&#x66;or the connection.  
10. Repeat steps 2-8 for the round-down tag and configure the following: 
    - In the *DataHub Subscribe* processor, select the alias topic for the **RoundDown&#x20;**&#x74;ag.
    - In the *method dropdown*, select **roundDown**. 
    - When you connect the two processors, select **Events&#xA0;**&#x61;nd enter a definition of **rounddown&#xA0;**&#x66;or the connection. 
11. Repeat steps 2-8 for the round-even tag and configure the following:
    - In the *DataHub Subscribe* processor, select the alias topic for the **RoundEven&#x20;**&#x74;ag. 
    - In the *method dropdown*, select **roundEven**. 
    - When you connect the two processors, select **Events&#xA0;**&#x61;nd enter a definition of **roundeven&#xA0;**&#x66;or the connection. 
12. On the analytics canvas, click **Save**.

The configured analytics flows should look like the following.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/P9Jo5nWaq3T1TYM4t28iG_image.png" size="80" width="772" height="798" position="center" caption="Completed Rounding Function in Analytics flows canvas" showCaption="true"}

# Step 4: View Rounded Data

You can view data on the analytics canvas by clicking the **View&#xA0;**&#x69;con in each *Rounding&#xA0;*&#x70;rocessor. 

## Round Data for RoundNearest Tag

The *roundNearest* method returns **2** as the answer when **1.523&#x20;**&#x69;s used as an input value.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/_7DbnwYOJcT3BhPvy38C9_image.png" size="80" width="506" height="647" position="center" caption="Rounding to nearest decimal" showCaption="true"}

## Round Data for RoundUp Tag

The *roundUp&#x20;*&#x6D;ethod returns **1.53** as the answer when **1.523&#x20;**&#x69;s used as an input value.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/JNw-79tWpt1Yg36xe0c75_image.png" size="80" width="511" height="635" position="center" caption="Rounding up to nearest decimal" showCaption="true"}

## Round Data for RoundDown Tag

The *roundDown&#x20;*&#x6D;ethod returns **1.52&#x20;**&#x61;s the answer when **1.523&#x20;**&#x69;s used as an input value.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/_Y7LduYd6PESEkG-oQ_eI_image.png" size="80" width="489" height="642" position="center" caption="Rounding down to nearest decimal" showCaption="true"}

## Round Data for RoundEven Tag

The *roundEven&#x20;*&#x6D;ethod returns **2** as the answer when **1.523&#x20;**&#x69;s used as an input value.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/2mTIK5dx6VNrJ3DpUG9Bs_image.png" size="80" width="520" height="641" position="center" caption="Rounding even to nearest decimal" showCaption="true"}

