package common;

public class NumberUtils {
	public static int atoi(String numberString) {
		if (numberString.length() == 0) {
			throw new java.lang.NumberFormatException(
					"The number string is empty.");
		}

		boolean isNegative = false;
		int startIndex = 0;
		if (numberString.charAt(0) == '-') {
			isNegative = true;
			startIndex = 1;
		} else if (numberString.charAt(0) == '+') {
			startIndex = 1;
		}

		if (startIndex == 1 && numberString.length() == 1) {
			throw new NumberFormatException("The string is malformed.");
		}

		int num = 0;
		for (int index = startIndex; index < numberString.length(); index++) {
			if (!Character.isDigit(numberString.charAt(index))) {
				throw new NumberFormatException("The string is malformed");
			}

			num = num * 10 + (numberString.charAt(index) - '0');
		}

		return isNegative ? num * -1 : num;
	}
}

@@ -850,11 +850,844 @@
  num;%0A%09%7D
+%0A%0A%09public static String itoa(int number) %7B%0A%09%09int length = length(number);%0A%09%09if (number %3C 0) %7B%0A%09%09%09length++;%0A%09%09%7D%0A%0A%09%09char%5B%5D digits = new char%5Blength%5D;%0A%09%09if (number == 0) %7B%0A%09%09%09digits%5B0%5D = '0';%0A%09%09%7D%0A%09%09if (number %3C 0) %7B%0A%09%09%09digits%5B0%5D = '-';%0A%09%09%09number *= -1;%0A%09%09%7D%0A%0A%09%09for (int index = length - 1; number != 0; index--, number /= 10) %7B%0A%09%09%09digits%5Bindex%5D = (char) ('0' + number %25 10);%0A%09%09%7D%0A%0A%09%09return new String(digits);%0A%09%7D%0A%0A%09public static int length(int number) %7B%0A%09%09if (number == 0) %7B%0A%09%09%09return 1;%0A%09%09%7D%0A%0A%09%09int length;%0A%09%09for (length = 0; number != 0; number /= 10, length++)%0A%09%09%09;%0A%0A%09%09return length;%0A%09%7D%0A%0A%09public static int reverse(int x) %7B%0A%09%09int given = x;%0A%09%09int reversed = 0;%0A%0A%09%09while (x %25 10 == 0 && x != 0) %7B%0A%09%09%09x /= 10;%0A%09%09%7D%0A%0A%09%09while (x != 0) %7B%0A%09%09%09reversed = x %25 10 + reversed * 10;%0A%09%09%09x /= 10;%0A%09%09%7D%0A%0A%09%09return given %3C 0 ? reversed * -1 : reversed;%0A%09%7D
 %0A%7D%0A

Add math functions.