Set specific precision of a BigDecimal
I have an XSD that requires me to use a BigDecimal for a lat/lon. I currently have the lat/lon as doubles, and convert them to BigDecimal, but I am only required to use about 12 places of precision. I have not been able to figure out how to set that. Can anyone help me with this? You can use setScale() e.g. double d = ... BigDecimal db = new BigDecimal(d).setScale(12, BigDecimal.ROUND_HALF_UP); The title of the question asks about precision. BigDecimal distinguishes between scale and precision. Scale is the number of decimal places. You can think of precision as the number of significant