您的位置:首页 > 编程语言 > Java开发

java Math.round()

2012-11-05 20:43 579 查看


java
Math.round()

?
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
        int a=Math.round(11.5f);
        System.out.println(a);
        long b=Math.round(-11.5);
        System.out.println(b);
	}

}
/*
12
-11
 */


public class MthRound {  
    public static void main(String[] args) throws Exception {  
        //int i=Math.round(11.5);
		System.out.println(Math.round(11.5));
		//int j=Math.round(-11.5);
		System.out.println(Math.round(-11.5));
		System.out.println(Math.round(-11.4));
		System.out.println(Math.round(-11.6));
    }  
}  
/*
12
-11
-11
-12
*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: