-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Labels:
Description
Description:
New $round function + precision argument for $trunc function
Engineering Ticket Description:
Inclusion of an $int or $round operator, which can reliably group numbers which are semantically the same is thus desired.
Example:
In attempting to perform bucketing in an aggregation pipeline, where the buckets are defined as "each Xth of range Y", these functions are needed.bucket = int( (x - min) / (max - min) * bucket_count ) // This relies on the int() function removing any real part of the number. // At a semantic level, the following is the same: bucket = (x - min - mod(x - min, (max - min) * bucket_count) / ((max - min) / bucket_count)Since this is all floating point math it is subject to errors such as 1.000000001 vs 0.999999999, and therefor less accurate.
Scope of changes
- Update $trunc with new syntax, noting original syntax is still valid
- Create $round docs and link appropriately
- Crosslink between $trunc and $round for users on one page looking for functionality of the other
- update 4.2 release notes
- documents
-
SERVER-15926 Add $round and/or $integer floating-point functions
- Closed