首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

对数目字进行四舍五入的方法

2012-12-24 
对数字进行四舍五入的方法使用Math中的round方法import java.util.*public class qwe {public static voi

对数字进行四舍五入的方法
使用Math中的round方法

import java.util.*;public class qwe {public static void main(String[] args) {double above = 0.7, below = 0.4;float fabove = 0.7f, fbelow = 0.4f;System.out.println("Math.round(above)" + Math.round(above));System.out.println("Math.round(above)" + Math.round(below));System.out.println("Math.round(above)" + Math.round(fabove));System.out.println("Math.round(above)" + Math.round(fbelow));}}



结果为:1
       0
       1
       0

热点排行