@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptMalformedScientificNumbers() { scientificNotation.calculate("9.18F+09"); }
public long calculate(String number) { if (number == null || !number.contains("E")) { throw new IllegalArgumentException("Invalid format for number " + number); } String[] splittedNumber = splitScientificNumber(number); double first = getLeftPart(splittedNumber[0]); int sign = getNumberSign(splittedNumber[1]); int pow = getPow(splittedNumber[1]); Double result = sign * first * Math.pow(10, pow); return result.longValue(); }
ScientificNotation { public long calculate(String number) { if (number == null || !number.contains("E")) { throw new IllegalArgumentException("Invalid format for number " + number); } String[] splittedNumber = splitScientificNumber(number); double first = getLeftPart(splittedNumber[0]); int sign = getNumberSign(splittedNumber[1]); int pow = getPow(splittedNumber[1]); Double result = sign * first * Math.pow(10, pow); return result.longValue(); } }
ScientificNotation { public long calculate(String number) { if (number == null || !number.contains("E")) { throw new IllegalArgumentException("Invalid format for number " + number); } String[] splittedNumber = splitScientificNumber(number); double first = getLeftPart(splittedNumber[0]); int sign = getNumberSign(splittedNumber[1]); int pow = getPow(splittedNumber[1]); Double result = sign * first * Math.pow(10, pow); return result.longValue(); }  }
ScientificNotation { public long calculate(String number) { if (number == null || !number.contains("E")) { throw new IllegalArgumentException("Invalid format for number " + number); } String[] splittedNumber = splitScientificNumber(number); double first = getLeftPart(splittedNumber[0]); int sign = getNumberSign(splittedNumber[1]); int pow = getPow(splittedNumber[1]); Double result = sign * first * Math.pow(10, pow); return result.longValue(); }  long calculate(String number); }
ScientificNotation { public long calculate(String number) { if (number == null || !number.contains("E")) { throw new IllegalArgumentException("Invalid format for number " + number); } String[] splittedNumber = splitScientificNumber(number); double first = getLeftPart(splittedNumber[0]); int sign = getNumberSign(splittedNumber[1]); int pow = getPow(splittedNumber[1]); Double result = sign * first * Math.pow(10, pow); return result.longValue(); }  long calculate(String number);  }