# Convert scientific notation (ex: 7.533992951114973E-4) to float

**URL:** https://discuss.elastic.co/t/convert-scientific-notation-ex-7-533992951114973e-4-to-float/254482
**Category:** Elasticsearch
**Tags:** painless
**Created:** [November 6, 2020, 4:25am UTC](https://discuss.elastic.co/t/convert-scientific-notation-ex-7-533992951114973e-4-to-float/254482 "2020-11-06T04:25:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)
#### Post date: [November 6, 2020, 4:25am UTC](https://discuss.elastic.co/t/convert-scientific-notation-ex-7-533992951114973e-4-to-float/254482/1 "2020-11-06T04:25:38Z")

</div>

Im trying to add the actual and typical field to the ML alerts on watcher, is there a method in painless to convert scientific notation to float?

```auto
                "actual" : [
                  7.533992951114973E-4
                ],

```

---

<div class="post-metadata">

### Author: ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)
#### Post date: [November 9, 2020, 3:08pm UTC](https://discuss.elastic.co/t/convert-scientific-notation-ex-7-533992951114973e-4-to-float/254482/2 "2020-11-09T15:08:35Z")

</div>

maybe something like:

```auto
         def actual = "7.533992951114973E-4";
          DecimalFormat df = new DecimalFormat();
          df.setMaximumFractionDigits(8);
          float a = Float.parseFloat((actual));
          return df.format(a);

```

output would be:

```auto
          "new_actual" : [
            "0.0007534"
          ]

```

---

<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 7, 2020, 3:08pm UTC](https://discuss.elastic.co/t/convert-scientific-notation-ex-7-533992951114973e-4-to-float/254482/3 "2020-12-07T15:08:47Z")

</div>

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