Skip to content

Commit dbfbdbd

Browse files
authored
DOCS 16507 clarify output of mod operator (#5550)
* DOCS-16507 mod output type * DOCS-16507 adding tag * DOCS-16507 adding tag * DOCS-16507 adding tag * DOCS-16507 copy edits * DOCSP-16507 tech edit * DOCSP-16507 tech edit * DOCS-16507 tech edits * DOCS-16507 tech edits * DOCS-16507 tech edits * Empty-Commit
1 parent 0d963bb commit dbfbdbd

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

source/reference/operator/aggregation/mod.txt

+24
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ $mod (aggregation)
44

55
.. default-domain:: mongodb
66

7+
.. facet::
8+
:name: genre
9+
:values: reference
10+
11+
.. meta::
12+
:keywords: code example
13+
714
.. contents:: On this page
815
:local:
916
:backlinks: none
@@ -30,6 +37,23 @@ Definition
3037
<aggregation-expressions>` as long as they resolve to numbers. For
3138
more information on expressions, see :ref:`aggregation-expressions`.
3239

40+
Starting in version 7.2, the output data type of the ``$mod`` operator is
41+
the larger of the two input data types.
42+
43+
.. note::
44+
45+
Prior to version 7.2, the value and field type of inputs determine
46+
the ``$mod`` output type if:
47+
48+
- The divisor is of data type ``double`` but has an integral
49+
value.
50+
51+
- The dividend is of data type ``int`` or ``long``.
52+
53+
In this case, MongoDB converts the divisor to the dividend data
54+
type before it performs the mod operation and the output data type
55+
is the dividend data type.
56+
3357
Example
3458
-------
3559

source/reference/operator/query/mod.txt

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ $mod
44

55
.. default-domain:: mongodb
66

7+
.. facet::
8+
:name: genre
9+
:values: reference
10+
11+
.. meta::
12+
:keywords: code example
13+
714
.. contents:: On this page
815
:local:
916
:backlinks: none
@@ -26,9 +33,10 @@ $mod
2633
Behavior
2734
--------
2835

29-
The ``$mod`` operator returns an error if the ``[ divisor, remainder ]`` array
30-
contains fewer or more than two elements. For examples, see
31-
:ref:`mod-not-enough-elements` and :ref:`mod-too-many-elements` respectively.
36+
``$mod`` returns an error if the ``[ divisor, remainder ]`` array
37+
doesn't contain two elements. For examples, see
38+
:ref:`mod-not-enough-elements` and :ref:`mod-too-many-elements`
39+
respectively.
3240

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

0 commit comments

Comments
 (0)