java中实现四舍五入
来源:互联网 发布:微信分身清除数据 编辑:程序博客网 时间:2024/05/01 19:19
<script type="text/javascript">google_ad_client = "pub-8800625213955058";/* 336x280, 创建于 07-11-21 */google_ad_slot = "0989131976";google_ad_width = 336;google_ad_height = 280;//</script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>public int getRound(double dSource){ int iRound //BigDecimal的构造函数参数类型是double BigDecimal deSource = new BigDecimal(dSource); //deSource.setScale(0,BigDecimal.ROUND_HALF_UP) 返回值类型 BigDecimal //intValue() 方法将BigDecimal转化为int iRound= deSource.setScale(0,BigDecimal.ROUND_HALF_UP).intValue(); return iRound;}