# Mutate decimal to long with implied decimal places

**URL:** https://discuss.elastic.co/t/mutate-decimal-to-long-with-implied-decimal-places/53694
**Category:** Logstash
**Created:** [June 22, 2016, 5:31pm UTC](https://discuss.elastic.co/t/mutate-decimal-to-long-with-implied-decimal-places/53694 "2016-06-22T17:31:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mwilicap](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@mwilicap](https://discuss.elastic.co/u/mwilicap)
#### Post date: [June 22, 2016, 5:31pm UTC](https://discuss.elastic.co/t/mutate-decimal-to-long-with-implied-decimal-places/53694/1 "2016-06-22T17:31:38Z")

</div>

Hello.

Is there a way in logstash to mutate an input field which is a string representation of a decimal (eg. "2387.74") to a long representation of the number with implied decimal places? Ie. We'd like to store that string in elasticsearch as 238774.

We want to do this so we can perform aggregations on them without the rounding errors we'd incur from using doubles.

Thank you

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [July 4, 2016, 6:27pm UTC](https://discuss.elastic.co/t/mutate-decimal-to-long-with-implied-decimal-places/53694/2 "2016-07-04T18:27:08Z")

</div>

You can use the mutate filter's gsub option to strip any decimals after the two first and remove the decimal point. Then use another mutate filter to convert the field to an integer. Or, use a ruby filter that does `event['name-of-field'] = (event['name-of-field'].to_f * 100).to_i`.

---

<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: [July 6, 2017, 4:49am UTC](https://discuss.elastic.co/t/mutate-decimal-to-long-with-implied-decimal-places/53694/3 "2017-07-06T04:49:43Z")

</div>


