@Test(expected = ArithmeticException.class) public void testArithmeticExceptionIsThrownIfTheBaseOfALogarithmIsLessThanZero() { MathUtils.logarithm(-3, 2); }
public static double logarithm(double base, double argument) { if (base <= 0 || argument <= 0) { throw new ArithmeticException("Base and argument of logarithms must be greater than 0"); } double answer = Math.log(argument) / Math.log(base); if (Double.isInfinite(answer)) { throw new ArithmeticException("Base of logarithm must be positive and not equal to 1"); } return answer; }
MathUtils { public static double logarithm(double base, double argument) { if (base <= 0 || argument <= 0) { throw new ArithmeticException("Base and argument of logarithms must be greater than 0"); } double answer = Math.log(argument) / Math.log(base); if (Double.isInfinite(answer)) { throw new ArithmeticException("Base of logarithm must be positive and not equal to 1"); } return answer; } }
MathUtils { public static double logarithm(double base, double argument) { if (base <= 0 || argument <= 0) { throw new ArithmeticException("Base and argument of logarithms must be greater than 0"); } double answer = Math.log(argument) / Math.log(base); if (Double.isInfinite(answer)) { throw new ArithmeticException("Base of logarithm must be positive and not equal to 1"); } return answer; }  }
MathUtils { public static double logarithm(double base, double argument) { if (base <= 0 || argument <= 0) { throw new ArithmeticException("Base and argument of logarithms must be greater than 0"); } double answer = Math.log(argument) / Math.log(base); if (Double.isInfinite(answer)) { throw new ArithmeticException("Base of logarithm must be positive and not equal to 1"); } return answer; }  static double logarithm(double base, double argument); }
MathUtils { public static double logarithm(double base, double argument) { if (base <= 0 || argument <= 0) { throw new ArithmeticException("Base and argument of logarithms must be greater than 0"); } double answer = Math.log(argument) / Math.log(base); if (Double.isInfinite(answer)) { throw new ArithmeticException("Base of logarithm must be positive and not equal to 1"); } return answer; }  static double logarithm(double base, double argument);  }