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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -