`
caryt
  • 浏览: 8556 次
文章分类
社区版块
存档分类
最新评论

JAVA舍入,截尾测试

 
阅读更多
/**
*
* @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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics