parseDouble return scientific computing number  
Author Message
quickcur





PostPosted: 2004-11-28 21:42:00 Top

java-programmer, parseDouble return scientific computing number if I use Double.parseDouble("0.0005"), it will return 5 E-4. How can I
get 0.0005? Thanks,

qq
 
Andrew Thompson





PostPosted: 2004-11-28 22:15:00 Top

java-programmer >> parseDouble return scientific computing number On 28 Nov 2004 05:42:22 -0800, Quick Function wrote:

> if I use Double.parseDouble("0.0005"), it will return 5 E-4. How can I
> get 0.0005?

<http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html>

HTH

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
 
Michael Borgwardt





PostPosted: 2004-11-29 4:17:00 Top

java-programmer >> parseDouble return scientific computing number Quick Function wrote:

> if I use Double.parseDouble("0.0005"), it will return 5 E-4. How can I
> get 0.0005?

You already *have* 0.0005. "0.0005" and "5e-4" are different representations
of the same abstract number, and parseDouble() returns the number, not any
particular representation (well, internally it's of course represented in
a different, third way, namely IEEE 754).

Your problem is not with parseDouble(), but with the way you're converting
the abstract number back into a String representation later on. If you want
to control that conversion, you have to use java.text.DecimalFormat.format()
instead of just doing something like System.out.println(number);