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

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

SQL Server - MyCTE query based on 24 hour period (next day) -