Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: JRuby 1.6.7
    • Fix Version/s: JRuby 1.6.7
    • Component/s: Application Error
    • Labels:
    • Environment:
      Linux WW637V18660A 2.6.32-37-generic-pae #81-Ubuntu
    • Number of attachments :
      0

      Description

      JRuby 1.6.7 is not returning the correct result when 'Math.log10(1000)' is executed. See code snippet below:

      $ irb
      jruby-1.6.7 :001 > Math.log10(1000)
       => 2.9999999999999996 
      

      What should be returned is in fact 3.0.

      The same calculation performed using other variants of JRuby below...

      JRuby 1.6.4:

      jruby-1.6.4 :002 >   Math.log10(1000)
       => 3.0
      

      JRuby 1.6.5:

      jruby-1.6.5 :001 > Math.log10(1000)
       => 3.0
      

      System details below...

      $ rvm info
      
      jruby-1.6.7@j2oomee:
      
        system:
          uname:       "Linux WW637V18660A 2.6.32-37-generic-pae #81-Ubuntu SMP Fri Dec 2 22:24:22 UTC 2011 i686 GNU/Linux"
          bash:        "/bin/bash => GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)"
          zsh:         " => not installed"
      
        rvm:
          version:      "rvm 1.9.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"
      
        ruby:
          interpreter:  "jruby"
          version:      "1.6.7"
          date:         "2012-02-22"
          platform:     "linux-i386-java"
          patchlevel:   "TM"
          full_version: "jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (Java HotSpot(TM) Server VM 1.6.0_22) [linux-i386-java]"
      
        homes:
          gem:          "/home/drathbon/.rvm/gems/jruby-1.6.7@j2oomee"
          ruby:         "/home/drathbon/.rvm/rubies/jruby-1.6.7"
      
        binaries:
          ruby:         "/home/drathbon/.rvm/rubies/jruby-1.6.7/bin/ruby"
          irb:          "/home/drathbon/.rvm/rubies/jruby-1.6.7/bin/irb"
          gem:          "/home/drathbon/.rvm/rubies/jruby-1.6.7/bin/gem"
          rake:         "/home/drathbon/.rvm/gems/jruby-1.6.7@j2oomee/bin/rake"
      

        Issue Links

          Activity

          Hide
          Hiro Asari added a comment -

          The values are the same, but we are displaying the result with greater precision in the 1.9 mode, and now we are seeing the shortcomings of the floating point arithmetic.

          There is no format that we can specify which satisfies both this and the test case shown in JRUBY-4846 (1.1 -0.9). So, I am not sure what we can do here.

          Show
          Hiro Asari added a comment - The values are the same, but we are displaying the result with greater precision in the 1.9 mode, and now we are seeing the shortcomings of the floating point arithmetic. There is no format that we can specify which satisfies both this and the test case shown in JRUBY-4846 (1.1 -0.9). So, I am not sure what we can do here.
          Hide
          Thomas E Enebo added a comment -

          I think this is a WONTFIX (although I will leave this open for a short period for comment). As Hiro pointed above we are displaying in a greater precision in 1.9 mode (MRI 1.9 also increased their precision as well). We are not matching 1.9.2 100% in output (I believe because we don't have unsigned values in Java), but you will see if you play around with values in both JRuby and MRI there will be long unexpected base 10 values depending on the values used. My college numerical analysis class has pounded in my head the stance that no one should ever be using direct equality (==) on a float that has been the result of a calculation ever. I know to_s is not == but the expectation is the same (specific value showing up).

          Show
          Thomas E Enebo added a comment - I think this is a WONTFIX (although I will leave this open for a short period for comment). As Hiro pointed above we are displaying in a greater precision in 1.9 mode (MRI 1.9 also increased their precision as well). We are not matching 1.9.2 100% in output (I believe because we don't have unsigned values in Java), but you will see if you play around with values in both JRuby and MRI there will be long unexpected base 10 values depending on the values used. My college numerical analysis class has pounded in my head the stance that no one should ever be using direct equality (==) on a float that has been the result of a calculation ever. I know to_s is not == but the expectation is the same (specific value showing up).
          Hide
          Hiro Asari added a comment -

          Resolving as "WONTFIX".

          Show
          Hiro Asari added a comment - Resolving as "WONTFIX".

            People

            • Assignee:
              Hiro Asari
              Reporter:
              Dylan Rathbone
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: