zoukankan      html  css  js  c++  java
  • 文章标题

             /** 
             * abs求绝对值 
             */  
            System.out.println(Math.abs(-10.4));    //10.4  
            System.out.println(Math.abs(10.1));     //10.1  
    
            /** 
             * ceil天花板的意思,就是返回大的值,注意一些特殊值 
             */  
            System.out.println(Math.ceil(-10.1));   //-10.0  
            System.out.println(Math.ceil(10.7));    //11.0  
            System.out.println(Math.ceil(-0.7));    //-0.0  
            System.out.println(Math.ceil(0.0));     //0.0  
            System.out.println(Math.ceil(-0.0));    //-0.0  
    
            /** 
             * floor地板的意思,就是返回小的值 
             */  
            System.out.println(Math.floor(-10.1));  //-11.0  
            System.out.println(Math.floor(10.7));   //10.0  
            System.out.println(Math.floor(-0.7));   //-1.0  
            System.out.println(Math.floor(0.0));    //0.0  
            System.out.println(Math.floor(-0.0));   //-0.0  
    
            /** 
             * max 两个中返回大的值,min和它相反,就不举例了 
             */  
            System.out.println(Math.max(-10.1, -10));   //-10.0  
            System.out.println(Math.max(10.7, 10));     //10.7  
            System.out.println(Math.max(0.0, -0.0));    //0.0  
    
            /** 
             * random 取得一个大于或者等于0.0小于不等于1.0的随机数 
             */  
            System.out.println(Math.random());  //0.08417657924317234  
            System.out.println(Math.random());  //0.43527904004403717  
    
            /** 
             * rint 四舍五入,返回double值 
             * 注意.5的时候会取偶数 
             */  
            System.out.println(Math.rint(10.1));    //10.0  
            System.out.println(Math.rint(10.7));    //11.0  
            System.out.println(Math.rint(11.5));    //12.0  
            System.out.println(Math.rint(10.5));    //10.0  
            System.out.println(Math.rint(10.51));   //11.0  
            System.out.println(Math.rint(-10.5));   //-10.0  
            System.out.println(Math.rint(-11.5));   //-12.0  
            System.out.println(Math.rint(-10.51));  //-11.0  
            System.out.println(Math.rint(-10.6));   //-11.0  
            System.out.println(Math.rint(-10.2));   //-10.0  
    
            /** 
             * round 四舍五入,float时返回int值,double时返回long值 
             */  
            System.out.println(Math.round(10.1));   //10  
            System.out.println(Math.round(10.7));   //11  
            System.out.println(Math.round(10.5));   //11  
            System.out.println(Math.round(10.51));  //11  
            System.out.println(Math.round(-10.5));  //-10  
            System.out.println(Math.round(-10.51)); //-11  
            System.out.println(Math.round(-10.6));  //-11  
            System.out.println(Math.round(-10.2));  //-10  
        }  
  • 相关阅读:
    FZU 2112 并查集、欧拉通路
    HDU 5686 斐波那契数列、Java求大数
    Codeforces 675C Money Transfers 思维题
    HDU 5687 字典树插入查找删除
    HDU 1532 最大流模板题
    HDU 5384 字典树、AC自动机
    山科第三届校赛总结
    HDU 2222 AC自动机模板题
    HDU 3911 线段树区间合并、异或取反操作
    CodeForces 615B Longtail Hedgehog
  • 原文地址:https://www.cnblogs.com/mrcharles/p/11879980.html
Copyright © 2011-2022 走看看