---
title: "How to round off a decimal number in JMX plugin without using Custom Format Masks?"
description: "Rounding off decimal numbers in the JMX plugin can be done using arithmetic expressions instead of Custom Format Masks. This method requires Netprobe GA6.7.0 or above and involves subtracting remainders or adding 0.5 before rounding down."
url: "https://docs.itrsgroup.com/docs/faq/geneos/115004027609-geneos-how-to-round-off-a-decimal-number-in-jmx-plugin-without-using-custom-format-masks/index.html"
---
**This can be achieved with [Custom Format Masks as discussed in another article](https://docs.itrsgroup.com/docs/faq/geneos/115004027589-geneos-how-to-use-custom-format-masks-in-jmx-for-output-formatting/index.html). We are also providing an alternative method with arithmetic expressions here.**

There was a known compatibility issue when using arithmetic expressions with newer Java versions (e.g. JDK 17 and above). Please make sure that you have **Netprobe version GA6.7.0 and above**.  In this example, we are trying to capture version numbers from the MBeans under **java.lang:type=Runtime**. The values for **ManagementSpecVersion** and **SpecVersion** are **1.2** and **1.8** respectively in our case.  **Case 1: Round down a decimal number** The original value can be represented as $1.SpecVersion. To round down the value, the logic is take the value and minus the remainder of itself divided by 1.

```
$1.SpecVersion - $1.SpecVersion % 1
```

**Case 2: Round off to the nearest integer** A trick is used here to add 0.5 to the original value, then perform the Round Down calculation as case 1. The result would effectively be rounding off to the nearest integer.

```
($1.SpecVersion + 0.5) - ($1.SpecVersion + 0.5) % 1
```

Below is the Active Console output showing the original and rounded values.  ![Screenshot](https://docscdn.itrsgroup.com/faq/images/geneos/115004027609-6966128428957-mceclip0.png)  The sampler configuration in XML format has been attached as reference.

## Further Reading

- [JMX Plugin Documentation](https://docs.itrsgroup.com/docs/geneos/current/collection/jmx-server/index.html), section *Arithmetic Expression Support*

## Related downloads

- [jmx_rounding_test_sampler.xml.txt](/faq/downloads/geneos/115004027609-115007576365-jmx_rounding_test_sampler.xml.txt)


