无线&移动互联网技术研发

换位思考·····
posts - 19, comments - 53, trackbacks - 0, articles - 283
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Math 取整函数

Posted on 2009-10-17 13:42 Gavin.lee 阅读(844) 评论(0)  编辑  收藏 所属分类: java SE & EE
/**
 * 取整函数
 
*/

public class QuZheng {
    
public static void main(String[] args) {
        
//四舍五入   
        System.out.println(Math.round(3.40d));   //3
        System.out.println(Math.round(3.60d));   //4
        
//上取整   
        System.out.println(Math.ceil(3.4));   //4.0
        
//下取整   
        System.out.println(Math.floor(3.40));   //3.0
        
        System.out.println((
int)3.45);    //3
    }

}

只有注册用户登录后才能发表评论。


网站导航: