# Sum with negative fields (double type) strange result

**URL:** <https://discuss.elastic.co/t/sum-with-negative-fields-double-type-strange-result/263438>\
**Category:** Elasticsearch\
**Created:** [February 5, 2021, 4:43pm UTC](https://discuss.elastic.co/t/sum-with-negative-fields-double-type-strange-result/263438 "2021-02-05T16:43:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maurip00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maurip00/32/83498_2.png) [@Maurip00](https://discuss.elastic.co/u/Maurip00)\
**Post date:** [February 5, 2021, 4:43pm UTC](https://discuss.elastic.co/t/sum-with-negative-fields-double-type-strange-result/263438/1 "2021-02-05T16:43:00Z")

</div>

There is someone that could me explain why by this simple aggregation:

```auto
    > GET cfo1/_search
    > {
    > "size": 0,
    > "aggs": {
    > "NAME": {
    > "filter": {...},
    > "aggs": {
    > "somma": {
    > "sum": {
    > "field": "SommaDiOre_mens_Comm_CdC"
    > }
    > },
    > "aaa": {
    > "terms": {
    > "field": "SommaDiOre_mens_Comm_CdC",
    > "size": 12
    > }
    > }
    > }
    > }
    > }
    > }

```

I get this response with the sum that is not zero:

```auto
    > "aggregations" : {
    > "NAME" : {
    > "doc_count" : 11,
    > "aaa" : {
    > "doc_count_error_upper_bound" : 0,
    > "sum_other_doc_count" : 0,
    > "buckets" : [
    > {
    > "key" : -141.96,
    > "doc_count" : 1
    > },
    > {
    > "key" : -41.07,
    > "doc_count" : 1
    > },
    > {
    > "key" : -13.6,
    > "doc_count" : 1
    > },
    > {
    > "key" : -6.83,
    > "doc_count" : 1
    > },
    > {
    > "key" : -6.0,
    > "doc_count" : 1
    > },
    > {
    > "key" : 1.44,
    > "doc_count" : 1
    > },
    > {
    > "key" : 5.39,
    > "doc_count" : 1
    > },
    > {
    > "key" : 6.0,
    > "doc_count" : 1
    > },
    > {
    > "key" : 13.6,
    > "doc_count" : 1
    > },
    > {
    > "key" : 41.07,
    > "doc_count" : 1
    > },
    > {
    > "key" : 141.96,
    > "doc_count" : 1
    > }
    > ]
    > },
    > "somma" : {
    > "value" : 1.5987211554602254E-14

```

---

<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:** [March 5, 2021, 4:43pm UTC](https://discuss.elastic.co/t/sum-with-negative-fields-double-type-strange-result/263438/2 "2021-03-05T16:43:56Z")

</div>

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