Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-29401

sum of large negative numbers gives wrong results

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 5.5.0
    • 5.5.0
    • query
    • None
    • Untriaged
    • Unknown

    Description

      Consider the following 2 examples:

      Case1

      1. CREATE PRIMARY INDEX ON default
      2. INSERT INTO default (KEY, VALUE)  VALUES ("doc1",{ "f1" : -822337203685477580 })
      3. INSERT INTO default (KEY, VALUE)  VALUES ("doc2", { "f1" : -822337203685477580 })
      4. SELECT SUM(f1) FROM default
        {
          "$1": -1644674407370955300
        }
      ]
      

      The output should be -1644674407370955160.

      Case2

      1. CREATE PRIMARY INDEX ON default
      2. INSERT INTO default (KEY, VALUE)  VALUES ("doc1",{ "f1" : -822337203685477580 })
      3. INSERT INTO default (KEY, VALUE) VALUES ("doc2",{ "f1" : 10 })
      4. SELECT SUM(f1) FROM default
        {
          "$1": -822337203685477600
        }
      ]
      

      The output should be -822337203685477570.

      Looks like the result is getting rounded off due to conversion to float64. But as the number/result is within the int64 range, we may not need to convert to float64 in such cases.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              ajay.bhullar Ajay Bhullar
              deepkaran.salooja Deepkaran Salooja
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty