谢谢。明天再加100分酬谢!

解决方案 »

  1.   

     ceil和floor是两个相对的方法,ceil是求大于等于参数的最小整数,floor是求小于等于参数的最大整数.具体说明见文档.
    round这样计算:public static int round(float a)返回最接近参数的 int。结果将舍入为整数:加上 1/2,对结果调用 floor 并将所得结果强制转换为 int 类型。换句话说,结果等于以下表达式的值: (int)Math.floor(a + 0.5f)
      

  2.   

    double floor(double) 
    返回不大于该参数的最大整数 (最接近正无穷)的 double 型值。
    int round(double) 
    返回与该参数最接近的 long 型数。 (四舍五入)
    long round(float) 
    返回与该参数最接近的 int 型数。(四舍五入)
      

  3.   

    ceil,floor
    ceil就是靠近负坐标
    floor就是靠近正坐标
    这样好记点
      

  4.   

    ceil,floor 
    ceil就是靠近负坐标 
    floor就是靠近正坐标 这个说的不错,不过记得是整数哦。
    和数据库里的函数其实是一样的
      

  5.   


    public class MyTest {
      public static void main(String[] args) {
        double[] nums = { 1.4, 1.5, 1.6, -1.4, -1.5, -1.6 };
        for (double num : nums) {
          test(num);
        }
      }  private static void test(double num) {
        System.out.println("Math.floor(" + num + ")=" + Math.floor(num));
        System.out.println("Math.round(" + num + ")=" + Math.round(num));
        System.out.println("Math.ceil(" + num + ")=" + Math.ceil(num));
      }
    }运行结果
    Math.floor(1.4)=1.0
    Math.round(1.4)=1
    Math.ceil(1.4)=2.0
    Math.floor(1.5)=1.0
    Math.round(1.5)=2
    Math.ceil(1.5)=2.0
    Math.floor(1.6)=1.0
    Math.round(1.6)=2
    Math.ceil(1.6)=2.0
    Math.floor(-1.4)=-2.0
    Math.round(-1.4)=-1
    Math.ceil(-1.4)=-1.0
    Math.floor(-1.5)=-2.0
    Math.round(-1.5)=-1
    Math.ceil(-1.5)=-1.0
    Math.floor(-1.6)=-2.0
    Math.round(-1.6)=-2
    Math.ceil(-1.6)=-1.0
      

  6.   

    参考这个 http://www.java2000.net/p9612
      

  7.   

    [http://www.google.cn