Answers for "how to take only 2 digits after decimal in java"

1

how to get 2 decimal places in java

total = (double) 100 / listMember.size();
DecimalFormat df = new DecimalFormat("#.##");
String dx = df.format(total);
total = Double.valueOf(dx);
Posted by: Guest on July-31-2021
0

print float number with only four places after the decimal point in java

import java.text.DecimalFormat;
public class code{
  public static void main(String[] args){
		double area= 12.21564315;
       	DecimalFormat df = new DecimalFormat("0.0000");
       	System.out.println("A="+df.format(area));
  }
}
Posted by: Guest on March-07-2022

Code answers related to "how to take only 2 digits after decimal in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language