java - Transform a BigDecimal with a negative scale to a positive scale -
i getting bigdecimal values in scientific notation, i.e., 1e+3 , has scale of -3. how convert 1000 scale 0? see can use toplainstring() , there direct way of achieving this?
if understand correctly, d = d.setscale(0) work:
bigdecimal d = bigdecimal.valueof(1e3).setscale(-3); system.out.println(d.unscaledvalue()); d = d.setscale(0); system.out.println(d.unscaledvalue()); output is:
1 1000 note bigdecimal immutable, have reassign it.
Comments
Post a Comment