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

NumberLong.bottom does not return values

    Details

    • Operating System:
      Linux

      Description

      within the javascript shell several NumberLong.bottom, NumberLong.top does not return any value.

      s.
      NumberLong("5188220513171889152").bottom

      while surrounding values seems correct.
      NumberLong("5188220513171889151").bottom -> 2147572735
      NumberLong("5188220513171889153").bottom -> 2147572737

      some more testcases:
      NumberLong("5188220483643986944")
      NumberLong("5188220484180857856")
      NumberLong("5188220484717728768")
      NumberLong("5188220485254599680")
      NumberLong("5188220486328341504")
      NumberLong("5188220486865212416")
      NumberLong("5188220487402083328")
      NumberLong("5188220487938954240")
      NumberLong("5188220513171889152")
      NumberLong("5188220517466856448")
      NumberLong("5188220518003727360")
      NumberLong("5188220518540598272")
      NumberLong("5188220787512923136")
      NumberLong("5188220788049794048")
      NumberLong("5188220871264785408")
      NumberLong("5188220871801656320")

        Issue Links

          Activity

          Hide
          ecd93e7a ecd93e7a 16c19bcb added a comment -

          approx. failure in 40 cases out of 50000 values.

          Show
          ecd93e7a ecd93e7a 16c19bcb added a comment - approx. failure in 40 cases out of 50000 values.
          Hide
          antoine Antoine Girbal (Inactive) added a comment -

          It only uses top/bottom in case it cannot exactly represent the long value using a double value.
          We could always set them, but they are not supposed to be used directly, it's more an internal field.

          Show
          antoine Antoine Girbal (Inactive) added a comment - It only uses top/bottom in case it cannot exactly represent the long value using a double value. We could always set them, but they are not supposed to be used directly, it's more an internal field.
          Hide
          ecd93e7a ecd93e7a 16c19bcb added a comment -

          thank you for the Information.

          The distinction (if( top == null ) then value) can, of course, be done on application side.

          Without knowing those internal fields, working on a provided collection, there is no other way of evaluating arbitary stored 64bit values from NumberLong (afaik). For this I would like to vote, for having this fields externalized/documented.

          Show
          ecd93e7a ecd93e7a 16c19bcb added a comment - thank you for the Information. The distinction (if( top == null ) then value) can, of course, be done on application side. Without knowing those internal fields, working on a provided collection, there is no other way of evaluating arbitary stored 64bit values from NumberLong (afaik). For this I would like to vote, for having this fields externalized/documented.
          Hide
          antoine Antoine Girbal (Inactive) added a comment -

          we can improve the doc and add some convenience methods.

          Show
          antoine Antoine Girbal (Inactive) added a comment - we can improve the doc and add some convenience methods.
          Hide
          rubytuesdaydono Reuben Garrett added a comment -

          Convenience methods would be very helpful to perform arithmetic using, e.g., Google Closure's goog.math.Long. For example, bitsTop() could return 0 and bitsBottom() could return floatApprox for smaller values representable as 54-bit floats without loss of precision; otherwise, they could return top and bottom (respectively).

          Show
          rubytuesdaydono Reuben Garrett added a comment - Convenience methods would be very helpful to perform arithmetic using, e.g., Google Closure's goog.math.Long . For example, bitsTop() could return 0 and bitsBottom() could return floatApprox for smaller values representable as 54-bit floats without loss of precision; otherwise, they could return top and bottom (respectively).

            People

            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since reply:
                3 years, 31 weeks, 6 days ago
                Date of 1st Reply: