Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JRuby 1.0.1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:Mac OS X (10.4.9), Java 1.5.0_07-164
-
Testcase included:yes
-
Patch Submitted:Yes
-
Number of attachments :
Description
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.
Very good work. I'm sorry to say that I would love it if you could emulate the MRI behavior. It is idosyncracies like this that make the language we all love... =)