[DOCS-15806] [SERVER] Fix $round and $trunc docs to avoid stating that floating point input types are converted to integer output types Created: 15/Dec/22 Updated: 22/Jan/24 |
|
| Status: | Backlog |
| Project: | Documentation |
| Component/s: | manual, Server |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor - P4 |
| Reporter: | Xiaochen Wu | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | backlog, feature, typo | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Days since reply: | 1 year, 4 weeks, 5 days ago | ||||||||
| Description |
|
According to the document (): If rounding to a whole integer value, $round returns the value as an integer. But it actually always return double |
| Comments |
| Comment by David Storch [ 06/Jan/23 ] |
|
Thanks xiaochen.wu@mongodb.com! brenda.rodriguez@mongodb.com ashley.brown@mongodb.com sarah.olson@mongodb.com as discussed above, I've converted this from a SERVER ticket to a DOCS ticket. Hopefully this ticket is in the correct state to be picked up on the docs team's triage queue. The fix should be pretty straightforward. Instead of making it sound like $round and $trunc coerce floating point numbers to integers, we can just clarify that the output type for these expressions is always same as the input type (assuming that the input is a numeric type). |
| Comment by Xiaochen Wu [ 22/Dec/22 ] |
|
Sounds good to me, as long as we document the behavior correctly. brenda.rodriguez@mongodb.com, could you please help to convert the ticket type and track it? Thank you! |
| Comment by David Storch [ 22/Dec/22 ] |
|
Hey xiaochen.wu@mongodb.com, to clarify, are you referring to the following statement on the docs page for $round:
There is a similar note on the docs page for $trunc:
I would argue that this is simply a mistake in the documentation. My expectation would be that both $round and $trunc always preserve the type of the input – neither operation would ever require increased precision, so the mathematical result can always be represented faithfully using the same type as the input value. I would argue that it would be surprising for $round or $trunc to also do an implicit type conversion. Therefore, I propose that we convert this ticket to a DOCS ticket in order to fix the documentation to align with the implemented behavior in the server. Does that sound good to you xiaochen.wu@mongodb.com? I am going to move this ticket into "waiting for user input" state pending your thoughts on this. |