KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to format (and not round off) a double to 2 decimal places. I tried with: String s1 = "10.126"; Double f1 = Double.parseDouble(s1); DecimalFormat df = new DecimalFormat(".00"); System.out.println("f1"+df.format(f1)); Result: 10.13 But I require the output to be 10.12
Tags (comma-separated)
Save Edits
Cancel