---
title: "Math.round用法 ."
author: "hyh2011"
date: "2012-11-22T16:38:01Z"
tags: []
categories: ["编程语言"]
slug: "math-round"
draft: false
lastmod: "2012-11-22T16:38:01Z"
id: 1733414
url: "https://hyh2011.iteye.com/blog/1733414"
---

2012-11-22 16:18 0人阅读 [评论](http://hyh2011.iteye.com/admin/blogs/#comments)(0) [收藏]() [编辑](http://write.blog.csdn.net/postedit/8212960 "编辑") [删除]()

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

package com.buyli.interview.baseinfo;

 

/\**

 * @Copyright @ 2012

 * All right reserved

 * @version 创建时间：Created on 2012-11-22

 * @author 作者：Create by www.360buyli.com

 * @Email: 360buyli@gmail.com

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

 \*/

 

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