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

Aggregation $sum has some odd rounding erorrs.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.10, 3.2.0-rc0
    • 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"}}})

    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

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

            Dates

              Created:
              Updated:
              Resolved: