@Test(groups="1s", timeOut=60000) public void testDivCeil() throws Exception { Assert.assertEquals(1, MathUtils.divCeil(3,5)); Assert.assertEquals(0, MathUtils.divCeil(-3,5)); Assert.assertEquals(0, MathUtils.divCeil(3,-5)); Assert.assertEquals(1, MathUtils.divCeil(-3,-5)); Assert.assertEquals(-1, MathUtils.divCeil(-3,3)); Assert.assertEquals(0, MathUtils.divCeil(-1,3)); Assert.assertEquals(1, MathUtils.divCeil(3,3)); Assert.assertEquals(Integer.MIN_VALUE, MathUtils.divCeil(10,0)); }
public static int divCeil(int x, int y) { if (y == 0) { return Integer.MIN_VALUE; } else { int r = x / y; if ((x ^ y) > 0 && (r * y != x)) { r++; } return r; } }
MathUtils { public static int divCeil(int x, int y) { if (y == 0) { return Integer.MIN_VALUE; } else { int r = x / y; if ((x ^ y) > 0 && (r * y != x)) { r++; } return r; } } }
MathUtils { public static int divCeil(int x, int y) { if (y == 0) { return Integer.MIN_VALUE; } else { int r = x / y; if ((x ^ y) > 0 && (r * y != x)) { r++; } return r; } } private  MathUtils(); }
MathUtils { public static int divCeil(int x, int y) { if (y == 0) { return Integer.MIN_VALUE; } else { int r = x / y; if ((x ^ y) > 0 && (r * y != x)) { r++; } return r; } } private  MathUtils(); static long factorial(int n); static int combinaison(int n, int p); static boolean isPowerOfTwo(int x); static int pow(int value, int exp); static double log(double value, double exponent); static double roundedLog(double value, double exponent); static int sum(int[] values, int begin, int end); static int sumFrom(int[] values, int begin); static int sumTo(int[] values, int end); static int sum(int[] values); static int sum(int[][] values); static int max(int[] values); static int max(int[][] values); static int min(int[] values); static int min(int[][] values); static int divFloor(int x, int y); static int divCeil(int x, int y); static int safeAdd(int x, int y); static int safeSubstract(int x, int y); static int safeMultiply(int x, int y); static int safeCast(long x); static double log2(double a); }
MathUtils { public static int divCeil(int x, int y) { if (y == 0) { return Integer.MIN_VALUE; } else { int r = x / y; if ((x ^ y) > 0 && (r * y != x)) { r++; } return r; } } private  MathUtils(); static long factorial(int n); static int combinaison(int n, int p); static boolean isPowerOfTwo(int x); static int pow(int value, int exp); static double log(double value, double exponent); static double roundedLog(double value, double exponent); static int sum(int[] values, int begin, int end); static int sumFrom(int[] values, int begin); static int sumTo(int[] values, int end); static int sum(int[] values); static int sum(int[][] values); static int max(int[] values); static int max(int[][] values); static int min(int[] values); static int min(int[][] values); static int divFloor(int x, int y); static int divCeil(int x, int y); static int safeAdd(int x, int y); static int safeSubstract(int x, int y); static int safeMultiply(int x, int y); static int safeCast(long x); static double log2(double a); final static double ROUNDED_LOG_PRECISION; final static double LOG10_2; }