# Floating point precision in response

**URL:** <https://discuss.elastic.co/t/floating-point-precision-in-response/19841>\
**Category:** Elasticsearch\
**Created:** [September 17, 2014, 11:14am UTC](https://discuss.elastic.co/t/floating-point-precision-in-response/19841 "2014-09-17T11:14:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Bolis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomas_bolis/32/700_2.png) [@Thomas\_Bolis](https://discuss.elastic.co/u/Thomas_Bolis)\
**Post date:** [September 17, 2014, 11:14am UTC](https://discuss.elastic.co/t/floating-point-precision-in-response/19841/1 "2014-09-17T11:14:33Z")

</div>

Hi,

I have a quick question with regards the response of numeric values. I  
perform an aggregation with the sum aggregation and when I get back the  
response in a curl request the number is shown as follows:

"aggs":{

> "day\_clicks":{  
> "sum": {  
> "field" : "clicks"  
> }  
> }  
> }

response

...

> "doc\_count": 384,  
> "day\_clicks": {  
> "value":  
> _2.7372883E7_},  
> ....

If you noticed the _E7_ which is the floating point instead of just  
printing the actual number:

...

> "value":  
> _27372883_\*...\*

Has anyone faced a similar case? At what level is this happening? in  
elastiscearch's response or later. I have noticed in marvel/sense that the  
response is coming in this way and the transformation is happening client  
side. Is there a way to change that in the response of ES?

Thank you very much

Thomas

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e99a0e58-ea22-49a4-974e-8796c7941c74%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e99a0e58-ea22-49a4-974e-8796c7941c74%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)\
**Post date:** [September 28, 2014, 6:35pm UTC](https://discuss.elastic.co/t/floating-point-precision-in-response/19841/2 "2014-09-28T18:35:58Z")

</div>

Hi Thomas,

This is an annoying property of how JavaScript handles numerics. It makes  
no distinction between integer and floating point numbers and has some  
heuristics when to display numbers as one or the other. Sadly this one fell  
on the wrong side of what you'd expect.

This is only happening in the browsers. Elasticsearch's responses are  
formatted as you'd expect. You can validate by copying the request as curl  
(under the per request menu in Sense) and running it from a terminal.

Still working on a way to elegantly work around this one.

Cheers,  
Boaz

On Wednesday, September 17, 2014 1:14:33 PM UTC+2, Thomas wrote:

> Hi,
> 
> I have a quick question with regards the response of numeric values. I  
> perform an aggregation with the sum aggregation and when I get back the  
> response in a curl request the number is shown as follows:
> 
> "aggs":{
> 
> > "day\_clicks":{  
> > "sum": {  
> > "field" : "clicks"  
> > }  
> > }  
> > }
> 
> response
> 
> ...
> 
> > "doc\_count": 384,  
> > "day\_clicks": {  
> > "value":  
> > _2.7372883E7_},  
> > ....
> 
> If you noticed the _E7_ which is the floating point instead of just  
> printing the actual number:
> 
> ...
> 
> > "value":  
> > _27372883_\*...\*
> 
> Has anyone faced a similar case? At what level is this happening? in  
> elastiscearch's response or later. I have noticed in marvel/sense that the  
> response is coming in this way and the transformation is happening client  
> side. Is there a way to change that in the response of ES?
> 
> Thank you very much
> 
> Thomas

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/eb07d8c3-f66e-454d-b33f-6a213fee56cc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/eb07d8c3-f66e-454d-b33f-6a213fee56cc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:59am UTC](https://discuss.elastic.co/t/floating-point-precision-in-response/19841/3 "2017-07-06T00:59:28Z")

</div>


