简体   繁体   中英

Converting Floating Point to String

I'm pretty new to Java and I am currently working on a project where I need to work with Floating points .

I am trying to convert the value from 3.5E8 (Double value) to a string value of 350000000. I have looked on the internet but currently I can't find a solution.

采用:

new BigDecimal(yourValue).toPlainString();

try String.format

String str = String.format("%.0f",3.5E8);

or

String str = new DecimalFormat("#.#").format(3.5E8);

You can use the BigDecimal class , toPlainString() method :

Returns a string representation of this BigDecimal without an exponent field.

 System.out.println(new BigDecimal(doubleValue).toPlainString());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM