Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions source/reference/operator/query/mod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ $mod

{ field: { $mod: [ divisor, remainder ] } }

.. _mod-behavior:

Behavior
--------

The :query:`$mod` operator returns an error if the:

- ``[ divisor, remainder ]`` array contains fewer or more than
two elements. For examples, see :ref:`mod-not-enough-elements` and
:ref:`mod-too-many-elements` respectively.
The :query:`$mod` operator returns an error if the ``[ divisor,
remainder ]`` array contains fewer or more than two elements. For
examples, see :ref:`mod-not-enough-elements` and
:ref:`mod-too-many-elements` respectively.

- ``divisor`` or ``remainder`` values evaluate to:
Also, starting in MongoDB 5.1 (and 5.0.4 and 4.4.10), :query:`$mod`
returns an error if the ``divisor`` or ``remainder`` values evaluate to:

- ``NaN`` (not a number) or ``Infinity``.
- ``NaN`` (not a number) or ``Infinity``.

- A value that cannot be represented using a 64-bit integer.
- A value that cannot be represented using a 64-bit integer.

Examples
--------
Expand Down
7 changes: 7 additions & 0 deletions source/release-notes/5.1-compatibility.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ Auditing
General Changes
---------------

``$mod`` Error Behavior
~~~~~~~~~~~~~~~~~~~~~~~

Starting in MongoDB 5.1 (and 5.0.4 and 4.4.10), the :query:`$mod`
operator returns an error if the ``divisor`` or ``remainder`` values
evaluate to certain values. See :ref:`$mod behavior <mod-behavior>`.

Deprecations
------------

Expand Down