Hi, Dan, here's the answer I got from Joe Darcy, who worked on the BigDecimal feature for J2SE 5. I've cc'd him on this thread so he can respond directly to any followup questions you may have. I've also attached the slides he mentions in his email below...
Thanks, Joe, for your help on this! David ---- Greetings. The basic change to BigDecimal in jsr 13 was removing the restrictions on the value of scale; this enables true floating-point (fixed precision) rounding and necessitated the changes in toString behavior Dan has already noted. The possibility of the scale restriction going away was in the javadoc since 1.3.0; from the string constructor, "(If in the future this specification is amended to permit negative scales, the final step of zeroing the scale and adjusting the unscaled value will be eliminated.)" If you are looking at the numerical values of the BigDecimal objects, the JSR13 changes are very compatible. The basic situation is that given Old c1 = a1.add(b1) New c2 = a2.add(b2) if a1.equals(a2) and b1.equals(b2), then c1.equals(c2) and if a1.compareTo(a2) == 0 and b1.compareTo(b2) == 0, then c1.compareTo(c2) == 0. Basically, with JSR13 we have a much more compact representation for integral values; as long as you don't look at the details of the representation you won't observe any differences. There is a section on compatibility in my BigDecimal bof from 2004; feel free to send my slides along, <internal URL>/BigDecimal-bof.pdf. I added a method to generated the old-style string output, toPlainString, and there is a simple idiom to get pre-Tiger style numbers: BigDecimal bd = new BigDecimal(myString); if (bd.scale() < 0) bd = bd.setScale(0); -Joe Daniel John Debrunner wrote: > David Van Couvering wrote: > > >>Hi, Dan, still tracking this down, but I had to smile -- the first level >>answer I got back from the J2SE folks was that these changes were made >>as part of JSR13, which was driven by IBM. Maybe you should find the >>guys behind JSR13 and give them an earful :) > > > I've been asking them as well. > > Regardless the J2SE 5.0 documentation should be updated to list the > binary incompatibilities. I guess it's good that these are the first I > can remember for Java, so all in all it's been a good platform for > binary compatibility since JDK 1.1. > > Dan. >
BigDecimal-bof.pdf
Description: Adobe PDF document