Aggregation $sum has some odd rounding erorrs.

XMLWordPrintableJSON

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

      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
            Reporter:
            John Page
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: