Java 5 and the BigDecimal

Posted on September 10, 2006. Filed under: java |

A couple weeks ago a coworker pointed out this post, detailing a very subtle change in java.math.BigDecimal between Java 1.4 and 5. This past week I ran into a problem caused by another change in how BigDecimal works.

The application I’m working on uses the JT400 toolkit to access an IBM iSeries machine. I accidentally had the application using Java 5 instead of Java 1.4, and received an exception saying the JT400 library could not convert a BigDecimal from scientific notation. The code seemed to be assuming something about the string format of BigDecimals. Digging in, I found that the toString format has changed between the two versions of Java. A BigDecimal with a scale of seven digits will produce this from calling toString() under Java 1.4: 0.0000000. The same code in Java 5 produces: 0E-7.

I found a post on the subject at the JT400 forum. It includes a link to this bug at Sun, where you can get details why they changed this.

Make a Comment

Make a Comment: ( None so far )

blockquote and a tags work here.

  • Category Cloud

  • Twitter

  • Del.icio.us Links

Liked it here?
Why not try sites on the blogroll...