diff --git a/source/reference/operator/query/mod.txt b/source/reference/operator/query/mod.txt index 85ece0f04c7..b3a141c891c 100644 --- a/source/reference/operator/query/mod.txt +++ b/source/reference/operator/query/mod.txt @@ -117,3 +117,31 @@ operator with an array that contains four elements: "$err" : "bad query: BadValue malformed mod, too many elements", "code" : 16810 } + +Modulo with Decimal Divisors +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``modulo`` expression rounds down decimal input to the floor. + +The following examples demonstrates this behavior : + +.. code-block:: javascript + + db.inventory.find( { qty: { $mod: [ 4.0, 0 ] } } ) + + { _id: 1, item: 'abc123', qty: 0 } + { _id: 3, item: 'ijk123', qty: 12 } + + db.inventory.find( { qty: { $mod: [ 4.5, 0 ] } } ) + + { _id: 1, item: 'abc123', qty: 0 } + { _id: 3, item: 'ijk123', qty: 12 } + + db.inventory.find( { qty: { $mod: [ 4.99, 0 ] } } ) + + { _id: 1, item: 'abc123', qty: 0 } + { _id: 3, item: 'ijk123', qty: 12 } + +Each query applies 4 to the mod function regardless of decimal points +resulting in the same result set. +