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

Aggregation $sum has some odd rounding erorrs.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.10, 3.2.0-rc0
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Fully Compatible
    • ALL
    • 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"}}})

      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

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

              Created:
              Updated:
              Resolved: