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

Incorrect handling of NumberLong in $pow function

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v3.6, v3.4, v3.2

      Description

      $pow has issues where a NumberLong base of -1 is used with a NumberLong exponent of a negative odd value.

      For example:

      MongoDB Enterprise > db.v.aggregate({$project: {'a': { $pow: [ NumberLong(-1), NumberLong(-5) ]  },  'b' : { $pow: [ -1, NumberLong(-3) ]  }   }  })
      { "_id" : ObjectId("5a689c791de68d211f6234d6"), "a" : NumberLong(1), "b" : -1 }
      

      Removing the NumberLong from either argument causes the right answer. It seems to be related purely to the return type being NumberLong, though I can confirm there are no issues with positive odd exponents.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              charlie.swanson Charlie Swanson
              Reporter:
              patrick.meredith Patrick Meredith
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: