Math.round用法 .

  咱们在项目开发中少不了要开发报表,而对于数据的处理,用于很多的函数或是方法是必不可少的。其中就包括四舍五入的方法Math.round,这个的用法也是java面试题中常见的。下面是java代码是Math.round使用方法: java

package com.buyli.interview.baseinfo; 面试

 

/** 函数

 * @Copyright @ 2012 spa

 * All right reserved .net

 * @version 建立时间:Created on 2012-11-22 ip

 * @author 做者:Create by www.360buyli.com 开发

 * @Email : 360buyli@gmail.com get

 * @description java面试题中Math.round的用法 io

 */ class

 

public class RoundInterview {

         public static void main(String[] args) {

                   System.out.println("Math.round(11.5)输出:"+Math.round(11.5));

                   System.out.println("Math.round(-11.5)输出:"+Math.round(-11.5));

         }

}

所输出的结果是:

Math.round(11.5)输出:12

Math.round(-11.5)输出:-11

相关文章
相关标签/搜索