@Test(groups="1s", timeOut=60000) public void testSafeMultiply() { Assert.assertEquals(MathUtils.safeMultiply(1, 1), 1); Assert.assertEquals(MathUtils.safeMultiply(Integer.MAX_VALUE, 10), Integer.MAX_VALUE); Assert.assertEquals(MathUtils.safeSubstract(Integer.MIN_VALUE, 10), Integer.MIN_VALUE); }
public static int safeMultiply(int x, int y){ long r = (long)x * (long)y; if ((int)r != r) { return r > 0 ? Integer.MAX_VALUE:Integer.MIN_VALUE; } return (int)r; }
MathUtils { public static int safeMultiply(int x, int y){ long r = (long)x * (long)y; if ((int)r != r) { return r > 0 ? Integer.MAX_VALUE:Integer.MIN_VALUE; } return (int)r; } }
MathUtils { public static int safeMultiply(int x, int y){ long r = (long)x * (long)y; if ((int)r != r) { return r > 0 ? Integer.MAX_VALUE:Integer.MIN_VALUE; } return (int)r; } private  MathUtils(); }
MathUtils { public static int safeMultiply(int x, int y){ long r = (long)x * (long)y; if ((int)r != r) { return r > 0 ? Integer.MAX_VALUE:Integer.MIN_VALUE; } return (int)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 safeMultiply(int x, int y){ long r = (long)x * (long)y; if ((int)r != r) { return r > 0 ? Integer.MAX_VALUE:Integer.MIN_VALUE; } return (int)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; }