Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: JRuby 1.x+
    • Fix Version/s: None
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
      Ubunty Linux 7.10 x32,
      ruby 1.8.5 (2007-11-20 rev 4842) [i386-jruby1.1b1]
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      Hmm, this is a tricky one. It seems that JRuby and MRI have different limits to separate Fixnum and Bignum.

      And from the official ruby docs: "A Fixnum holds Integer values that can be represented in a native machine word (minus 1 bit). If any operation on a Fixnum exceeds this range, the value is automatically converted to a Bignum.".

      So, MRI uses 0x3fffffff as the biggest FixNum under 32bit environment.
      And JRuby always uses 64bit value: jruby -e 'p (0x7fffffffffffffff + 1).class' ---> Bignum.

      The differences are easy to see:

      1. ruby -e 'p (0x3fffffff + 1).class' ---> Bignum

      2. jruby -e 'p (0x3fffffff + 1).class' ---> Fixnum

      Also, this is a root cause for one test failure from rubinius specs:
      (basically, division by 0.0 behaves differently in case of FixNum or BigNum).

      Note: there is also a separate issue in the rubinius spec test, since the
      0x3fffffff + 1 value is hardcoded there, which is not correct for 64bit systems, based on the official spec quoted above.

      #>bin/mspec -t jruby spec/core/bignum
      .................F.E...............................................................

      2)
      Bignum#div does NOT raise ZeroDivisionError if other is zero and is a Float FAILED
      Infinity:
      /opt/work/rubinius/./spec/core/bignum/shared/divide.rb:17
      /opt/work/rubinius/./spec/core/bignum/shared/divide.rb:17:in `it'
      /opt/work/rubinius/spec/mini_rspec.rb:403:in `it'
      /opt/work/rubinius/./spec/core/bignum/shared/divide.rb:17:in `it'
      /opt/work/rubinius/./spec/core/bignum/shared/divide.rb:17:in `describe'
      /opt/work/rubinius/spec/mini_rspec.rb:399:in `describe'
      /opt/work/rubinius/./spec/core/bignum/shared/divide.rb:2:in `describe'
      /opt/work/rubinius/./spec/core/bignum/shared/divide.rb:2:in `call'
      /opt/work/rubinius/./spec/core/bignum/../../spec_helper.rb:154:in `it_behaves_like'
      /opt/work/rubinius/./spec/core/bignum/div_spec.rb:6:in `it_behaves_like'
      /opt/work/rubinius/./spec/core/bignum/div_spec.rb:5:in `describe'
      /opt/work/rubinius/spec/mini_rspec.rb:399:in `describe'
      /opt/work/rubinius/./spec/core/bignum/div_spec.rb:5:in `describe'
      /opt/work/rubinius/./spec/core/bignum/div_spec.rb:5:in `load'
      last_mspec.rb:11:in `load'
      last_mspec.rb:1:in `each'
      last_mspec.rb:6:in `each'

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        At this time, we will leave JRuby's Fixnum precision at 64-bit, since that's what Java provides us through native values. And we have since worked with rubyspecs to make them accept alternate precisions.

        Show
        Charles Oliver Nutter added a comment - At this time, we will leave JRuby's Fixnum precision at 64-bit, since that's what Java provides us through native values. And we have since worked with rubyspecs to make them accept alternate precisions.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Vladimir Sizikov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: