您的位置:首页 > 大数据 > 人工智能

retain two decimal digits.

2014-04-01 21:55 302 查看
package kju.o;
import static kju.print.Printer.*;
import java.text.*;
class MathDemo
{
public static void main(String[] args)
{
double d = 1.2458;
println(round(d));    //prints:1.25
}

static String round(double d)
{
DecimalFormat nf = new DecimalFormat("#.00");
return nf.format(d);    //retain two decimal digits.
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: