# Division Operation in Katalon

**URL:** <https://forum.katalon.com/t/division-operation-in-katalon/134981>\
**Category:** Miscellaneous\
**Created:** [June 17, 2024, 10:27pm UTC](https://forum.katalon.com/t/division-operation-in-katalon/134981 "2024-06-17T22:27:49Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [June 18, 2024, 12:12am UTC](https://forum.katalon.com/t/division-operation-in-katalon/134981/3 "2024-06-18T00:12:00Z")

</div>

I assume you can extract the “Premium” field from the UI. Otherwise, we will need to see the HTML of the field.  
With the “Premium” field, you can remove the dollar sign, with either a format or replace, like:

```auto
import java.text.DecimalFormat

def strPremium = ...
def premiumValue = strPremium.replace('$', '')
"divide by two as either 'float' or 'double' if really big numbers"
def resultSet = (premiumValue as float)/2.0
def strOutput = new DecimalFormat("###,##0.00").format(resultSet);

def otherOutput = ...
WebUI.comment("Your values are: ${strOutput} and ${otherOutput}")
WebUI.verifyMatch(strOutput, otherOutput, false) 

```

Edit: based on @kazurayam suggestion, I changed the double quotes to single quotes. see if that works for you. I ran the code on my machine with no issue (with assumed values).

> <https://stackoverflow.com/questions/58969993/fixed-decimal-places-java-groovy>

> [@Fighting with MAP formatting](http://forum.katalon.com/t/fighting-with-map-formatting/132746/5):
>
> Just for your information, see the following script import java.text.DecimalFormat Map\<String, Integer\> m = ["OnLoad":0] println "${m.get("OnLoad")}, ${m.get("OnLoad").getClass().getName()}" m.put("OnLoad", 1.2345) println "${m.get("OnLoad")}, ${m.get("OnLoad").getClass().getName()}" String s = new DecimalFormat("#,###,###,##0").format(m.get("OnLoad")); println "${s}, ${s.getClass().getName()}" and the output from it. 2024-06-05 19:50:51.587 INFO c.k.katalon.core.main.TestCaseExecutor - -…

---

_[View the full topic](https://forum.katalon.com/t/division-operation-in-katalon/134981)._
