# Small values getting rounded to zero on scripted field

**URL:** <https://discuss.elastic.co/t/small-values-getting-rounded-to-zero-on-scripted-field/128287>\
**Category:** Elasticsearch\
**Created:** [April 17, 2018, 5:48am UTC](https://discuss.elastic.co/t/small-values-getting-rounded-to-zero-on-scripted-field/128287 "2018-04-17T05:48:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DermotM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dermotm/32/30066_2.png) [@DermotM](https://discuss.elastic.co/u/DermotM)\
**Post date:** [April 17, 2018, 5:48am UTC](https://discuss.elastic.co/t/small-values-getting-rounded-to-zero-on-scripted-field/128287/1 "2018-04-17T05:48:05Z")

</div>

Hi folks, This one's got me stumped... I'm taking a really small value, and creating a scripted field to scale it, so that kibana can chart it nicely for me. But I'm losing precion somewhere and ending up with '0' instead of a scaled number.

Scripted field is pretty simple...

'GET Index-\*/\_search  
{  
"script\_fields": {  
"fields.ActualValue.mAmp": {  
"script": {  
"lang": "expression",  
"inline": "doc['fields.ActualValue.SIValue'].value \*1000000"  
}  
}  
}  
}'

The number I want to scale is pretty small, e.g. 0.00000492712  
In the image, you can see the scaled scripted variable fields.ActualValue.mAmp  
 ![scale%20problem](https://us1.discourse-cdn.com/elastic/original/3X/c/e/ce18717c62251f079386c68e4e9af68988ea53c7.png)

Obviously, when I chart this I get a flat line at zero.

Running the scripted field in Console - it works on any values that are greater than one, but appears to treat them as integers. Here's a sample output  
{  
"\_index": "Index-2018.03",  
"\_type": "logevent",  
"\_id": "AWJBHnfFKawtLpEL6hQe",  
"\_score": 1,  
"fields": {  
"NewActualValue": [  
0  
]  
}  
},  
{  
"\_index": "Index-2018.03",  
"\_type": "logevent",  
"\_id": "AWJBHnfFKawtLpEL6hQi",  
"\_score": 1,  
"fields": {  
"NewActualValue": [  
14000000  
]  
}  
}

Further to this the original field is mapped as a Long. So I don't know where I'm losing precision.

Any pointers for diagnosing or solving this issue, are greatly 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:** [May 15, 2018, 5:48am UTC](https://discuss.elastic.co/t/small-values-getting-rounded-to-zero-on-scripted-field/128287/2 "2018-05-15T05:48:20Z")

</div>

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