Details
-
Bug
-
Resolution: Won't Fix
-
Minor - P4
-
None
-
*Location*: http://docs.mongodb.org/manual/reference/operator/aggregation/mod/#exp._S_mod
*User-Agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/7.1.2 Safari/537.85.11
*Referrer*: http://docs.mongodb.org/manual/meta/aggregation-quick-reference/
*Screen Resolution*: 1440 x 900
*repo*: docs
*source*: reference/operator/aggregation/mod
*Location*: http://docs.mongodb.org/manual/reference/operator/aggregation/mod/#exp._S_mod *User-Agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/7.1.2 Safari/537.85.11 *Referrer*: http://docs.mongodb.org/manual/meta/aggregation-quick-reference/ *Screen Resolution*: 1440 x 900 *repo*: docs *source*: reference/operator/aggregation/mod
-
0.25
Description
The $mod function doesn't describe how it behaves for negative numbers.
What's -1 % 10, for example? Programming languages are generally split on how to answer this question. Python and Ruby say 9, while Java and C say -1. A nonnegative result is arguably more (mathematically) correct, but MongoDB generally follows Javascript, so maybe it gives -1 here?
Whichever one MongoDB does today, I can figure out by trial-and-error, but since it's not documented, is it guaranteed to be stable?