上  math.floor
下  math.ceil
4/5 math.round

解决方案 »

  1.   

    看看java.math.BigDecimal中的几个常量
      

  2.   

    java.lang.math中的几个函数即可:四舍五入:
    static long round(double a) 
              Returns the closest long to the argument. 
    static int round(float a) 
              Returns the closest int to the argument. 
    下取整:
    static double ceil(double a) 
              Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer. 上取整:
    static double floor(double a) 
              Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer. 例如:double d = math.floor(23.34);  
           
      

  3.   

    import java.lang.*;public class quzheng{
        public static void main(String args[]){
            //四舍五入
            System.out.println(Math.round(3.40d));
            System.out.println(Math.round(3.60d));
            System.out.println(Math.round(3.40f));
            System.out.println(Math.round(3.60f));
            //上取整
            System.out.println(Math.ceil(3.4));
            System.out.println(Math.ceil(3.6));
            //下取整
            System.out.println(Math.floor(3.40));
            System.out.println(Math.floor(3.60));
        }
    }