• Post Reply Bookmark Topic Watch Topic
  • New Topic

fraction point problem  RSS feed

 
narayana murthy pedapudi
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want to get the rewuired numbers of the decimal part...
like 3.45678 then i need 3.45 or 3.4567...
please let me know is there any function to get these values..
narayana
 
Ananth Murthy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.text.*;
double num = 10.390039954;
DecimalFormat df = new DecimalFormat("#0.000");
System.out.println(df.format(num));

//the output you get is 10.390
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!