[原创]为何不等
public class Dec {
public static void main (String arg[])
{
double b1=36.48;
double b2=5.51;
double b3=b1+b2 ;
System.out.println("b3 is "+b3);
}
}
wei he zhe liang ge shu jia qi lai bu xiang deng
import java.text.DecimalFormat;//导入一个控制数据格式的类就可以控制你输出数的位数了
public class Xx{
public static void main (String arg[])
{
double b1=36.48;
double b2=5.51;
double b3= b1+b2 ;
DecimalFormat num = new DecimalFormat("0.00");括号里的可以随便变成保留几位小数
System.out.println("b3 is "+num.format(b3));
}
}