optimization « bigdecimal « Java Data Type Q&A





1. BigDecimal: Can the Java compiler optimize away multiplications by 1?    stackoverflow.com

Does the Java compiler remove multiplications by 1, when talking about BigDecimal? I'm standing in something similar to this:

BigDecimal bd = getBigDecimal();//get arbitrary bigDecimal, could be anyone.

bd = bd.multiply(new BigDecimal(getOneTwoOrThree());
Where the getOneTwoOrThree ...

2. Analog of StringBuilder for BigDecimal    stackoverflow.com

I've got a list of BigDecimals to sum. If they were Strings to concatenate, I would use StringBuilder to reduce object creation. Is there something similar for BigDecimal? Or maybe I ...