Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
1  
Look at DecimalFormat. –  Andrew Thompson Jun 13 '13 at 12:29
    
System.out.println(new BigDecimal(f).toPlainString()); ? –  Alexis C. Jun 13 '13 at 12:30
    
way2java.com/string-and-stringbuffer/… + many other conversion/casting examples. Recomend to book –  Viliam Jun 13 '13 at 12:34
    
Although the answers so far will work for 3.5E8, they may not do what you want for some other inputs. You need to consider the range of inputs before selecting a solution. –  Patricia Shanahan Jun 13 '13 at 12:39

3 Answers 3

up vote 5 down vote accepted

Use:

new BigDecimal(yourValue).toPlainString();
share|improve this answer
    
Perfect, just what I wanted. Thank you. –  Michael Jun 13 '13 at 12:46

try String.format

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

or

String str = new DecimalFormat("#.#").format(3.5E8);
share|improve this answer

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());
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.