[DOCS-5400] Explain how $mod handles negative numbers Created: 08/May/15  Updated: 30/Oct/23  Resolved: 01/Nov/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Bug Priority: Minor - P4
Reporter: Docs Collector User (Inactive) Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: bite-sized, docs-triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

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


Participants:
Days since reply: 1 year, 14 weeks, 1 day ago
Epic Link: DOCSP-1769
Story Points: 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?



 Comments   
Comment by Education Bot [ 01/Nov/22 ]

Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!

Generated at Thu Feb 08 07:50:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.