java编程中怎么控制小数点后的位数

 时间:2026-02-12 19:29:36

//一般控制格式都是通过 DecimalFormat 来控制的import java.text.DecimalFormat;

public class ControlBit {

public static void main(String[] argu){

double money = 399.74099999999993;

DecimalFormat df=new DecimalFormat("#.00");

System.out.println(df.format(money));

}

}

java编程中怎么控制小数点后的位数

扩展资料

Decimalformat

import java.text.DecimalFormat;

public class NumberFormatDemo02

{

public static void main(String args[])

{

DecimalFormat df=new DecimalFormat("0.00");

String a = df.format(11.3265876);

String b = df.format(0.3526425);

System.out.println(a);

System.out.println(b);

}

}

参考资料:百度百科 Java

  • 夜神模拟器怎么卸载干净?
  • PyCharm如何设置项目的新建位置#校园分享#
  • wallpaper壁纸显示不出来
  • 更新win10后csgo等游戏FPS变低解决方法
  • 王国风云2 拜占庭皇帝如何改信
  • 热门搜索
    白砂糖洗脸有什么好处 exam是什么意思 淘宝小号是什么意思 树欲静而风不止是什么意思 地插什么牌子好 mango是什么意思 去澳大利亚买什么好 墓志铭是什么意思 新股什么时间申购中签率高 生日蛋糕祝福语