Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-15926

Add $round and/or $integer floating-point functions

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Backport Requested:
      v4.0

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              patrick.meredith Patrick Meredith
              Reporter:
              rod.adams Rod Adams
              Participants:
              Votes:
              12 Vote for this issue
              Watchers:
              23 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: