Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-20975

Aggregation $sum has some odd rounding erorrs.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.6.10, 3.2.0-rc0
    • Fix Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      db.b.insert({a:1.1})
      db.b.insert({a:0.1})
      db.b.aggregate({$group:{_id:true,t:{$sum:"$a"}}})
      

      Show
      db.b.insert({a:1.1}) db.b.insert({a:0.1}) db.b.aggregate({$group:{_id:true,t:{$sum:"$a"}}})

      Description

      If I use $sum to add some simple floating point numbers together in MongoDB 2.6 or 3.2 I see really odd rounding.

      db.b.insert({a:1.1})
      db.b.insert({a:0.1})
      db.b.aggregate({$group:{_id:true,t:{$sum:"$a"}}})
      { "_id" : true, "t" : 1.2000000000000002 }
      

      Same applies to 3.3 + 3.9 = 7.199999999999999

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            john.page John Page
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: