Implementing BigDecimal.mode()
------------------------------

                 Key: JRUBY-1120
                 URL: http://jira.codehaus.org/browse/JRUBY-1120
             Project: JRuby
          Issue Type: Improvement
          Components: Core Classes/Modules
         Environment: Mac OS X (10.4.9), Java 1.5.0_07-164
            Reporter: David Rupp
         Attachments: BigDecimal_mode_drupp.diff

I've done an implementation of BigDecimal.mode(), along with tests. 
Comments/suggestions welcome, as this is my first stab at a significant patch 
and I'm pretty sure I can use some help on style.

There are two things about the MRI implementation that I learned while doing 
this port. One is that MRI does not respect "composition" of exception modes in 
a single call. In MRI, if you do BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY 
| BigDecimal::EXCEPTION_NaN, true) the result is 2 (which is the value of 
BigDecimal::EXCEPTION_NaN, and which happens to be the last mode checked in the 
MRI code). This seems counterintuitive to me; my implementation for JRuby sets 
both in one call and returns 3. I could emulate MRI behavior here, but it's 
actually more work to do so!

The other issue is that MRI BigDecimal ignores exception modes other than 
BigDecimal::EXCEPTION_INFINITY and BigDecimal::EXCEPTION_NaN. There is simply 
no code to account for them. For consistency, I did not bother implementing the 
other exception modes, pending direction from the core team.

-- 
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