• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Who can handle the problem?

 
Steven Gao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code as follows:
public class testing{
public static void main(String argv[]){
double ii=123456789.12345;
System.out.println("ii="+ii);
}
}
The output is: ii=1.2345678912345E8
But I want to get: ii=123456789.12345
How can I do it? Is it any function to solve it?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default, numbers are formatted in scientific notation. The class java.text.DecimalFormat will help you do what you expect.
 
Steven Gao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic