The -1.30 floating point representation is not accurate. Here is a small modification to your code:
BigDecimal bd = new BigDecimal("-1.30").setScale(2, RoundingMode.HALF_UP); String textBD = bd.toPlainString(); System.out.println("text version, length = <" + textBD + ">, " + textBD.length()); int radixLoc = textBD.indexOf('.'); System.out.println("Fraction " + textBD.substring(0, radixLoc) + ". Cents: " + textBD.substring(radixLoc + 1, textBD.length()));
I set RoundingMode to setScale to round fractional pennies, for example, 1.295 half-up to 1.30.
Results:
text version, length = <-1.30>, 5 Fraction -1. Cents: 30
source share