# Painless script: can not write type \[class java.math.BigDecimal\]

**URL:** <https://discuss.elastic.co/t/painless-script-can-not-write-type-class-java-math-bigdecimal/288517>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [November 5, 2021, 6:30pm UTC](https://discuss.elastic.co/t/painless-script-can-not-write-type-class-java-math-bigdecimal/288517 "2021-11-05T18:30:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![catelling](https://avatars.discourse-cdn.com/v4/letter/c/3be4f8/32.png) [@catelling](https://discuss.elastic.co/u/catelling)\
**Post date:** [November 5, 2021, 6:30pm UTC](https://discuss.elastic.co/t/painless-script-can-not-write-type-class-java-math-bigdecimal/288517/1 "2021-11-05T18:30:43Z")

</div>

I am facing this exception on my discover page when trying to view my logs.  
Previously, I had a field involving BigDecimal and worked fine.  
this was the script:

```auto
if(!(doc[‘obyts.keyword’].size()==0)) {
    String b_str = doc[‘obyts.keyword’].value;
    BigDecimal bytes = new BigDecimal(b_str);
    BigDecimal eight = BigDecimal.valueOf(8.0);
    return bytes.multiply(eight).divide(BigDecimal.valueOf(1000000000L));
}

```

The script was to take bytes and change to Gigabits. Then i created a dashboard that was showing Gbps. I have scripted fields involving BigInteger that are working fine. I am new to ELK so any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 3, 2021, 6:31pm UTC](https://discuss.elastic.co/t/painless-script-can-not-write-type-class-java-math-bigdecimal/288517/2 "2021-12-03T18:31:36Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
