ITeye博客

JAVA舍入,截尾测试

caryt · 2013-06-27 11:35 · Markdown

/**
*
* @author caryt
*
*/
public class test {

/**
* @param args
*/

public static void main(String[] args) {
// TODO Auto-generated method stub

//结尾:
System.out.println("舍入截尾测试:"+(int)0.6f+" : "+(int)0.7);
//舍入需要round()方法

System.out.println("舍入:"+Math.round(0.6f)+" 舍入:"+Math.round(0.7)+" 截尾:"+Math.round(0.4f)+" 截尾:"+Math.round(0.4));

}

}

out: 舍入截尾测试:0 : 0
舍入:1 舍入:1 截尾:0截尾:0

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。