[1.9] RubyBignum#**, RubyFixnum#** and RubyFloat#** should return a RubyComplex 
if self is negative and raised to a fractional power
------------------------------------------------------------------------------------------------------------------------------------

                 Key: JRUBY-4255
                 URL: http://jira.codehaus.org/browse/JRUBY-4255
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules, Ruby 1.9
    Affects Versions: JRuby 1.4, JRuby 1.5
         Environment: github trunk, Java 6, Mac OS X 10.6.2
            Reporter: Hiro Asari
             Fix For: JRuby 1.5
         Attachments: 
0001-RubyBignum-RubyFixnum-and-RubyFloat-should-return-Ru.patch

Current trunk behavior:
{noformat}
surfboard:~$ jruby --1.9 -v -e 'p (-0x8000_0000_0000_0000-47)**(1/3.0)'
jruby 1.5.0.dev (ruby 1.9.2dev trunk 24787) (2009-11-20 5b30070) (Java 
HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]
-e:1 warning: (...) interpreted as grouped expression
-e:1: NaN (FloatDomainError)
surfboard:jruby[git:master]$ bin/jruby --1.9 -v -e 'p (-5)**(1/3.0)' 2>/dev/null
jruby 1.5.0.dev (ruby 1.9.2dev trunk 24787) (2009-11-20 5b30070) (Java 
HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]
NaN
surfboard:jruby[git:personal]$ bin/jruby --1.9 -v -e 'p (-1.25)**(1/3.0)' 
2>/dev/null
jruby 1.5.0.dev (ruby 1.9.2dev trunk 24787) (2009-11-20 5b30070) (Java 
HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]
NaN
{noformat}
MRI behavior:
{noformat}
surfboard:~$ ruby1.9 -v -e 'p (-0x8000_0000_0000_0000-47)**(1/3.0)'
ruby 1.9.2dev (2009-11-17 trunk 25805) [x86_64-darwin10.2.0]
-e:1: warning: (...) interpreted as grouped expression
(1048575.9999999994+1816186.9075973416i)
surfboard:jruby[git:master]$ ruby1.9 -v -e 'p (-5)**(1/3.0)' 2>/dev/null
ruby 1.9.2dev (2009-11-17 trunk 25805) [x86_64-darwin10.2.0]
(0.8549879733383486+1.480882609682364i)
surfboard:jruby[git:personal]$ ruby1.9 -v -e 'p (-1.25)**(1/3.0)' 2>/dev/null
ruby 1.9.2dev (2009-11-17 trunk 25805) [x86_64-darwin10.2.0]
(0.5386086725079711+0.932897586181032i)
{noformat}
While investigating JRUBY-4008, I noticed this bug. JRuby returns NaN where MRI 
returns a Complex.

The attached patch fixes this (and similar issues with RubyNumeric and 
RubyFloat).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to