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

dividing two integers always produces a double

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None

      Right now when one integer is divided by another the result is a double, even if the exact (unrounded) result could be expressed as an integer. This may be ok / desirable, but wanted to check.

      Test:

      c = db.c;
      c.drop();
      
      c.save( { a:NumberLong(10) } );
      printjson( c.aggregate(
      		       // Divide 10 by 1                                                          
                             { $project:{ z:{ $divide:[ '$a', NumberLong(1) ] } } },
      		       // Match where z is of type double.                                        
                             { $match:{ z:{ $type:1 } } }
                             ) );
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: