Interesting opinion. I pity the poor b... that have to maintain your code.
Here's some code from Sun's BigDecimal class. I guess they have a bunch of retards working there:
// should now be at numeric part of the significand
int dotoff = -1; // '.' offset, -1 if none
int cfirst = offset; // record start of integer
long exp = 0; // exponent
if (len > in.length) // protect against huge length
throw new NumberFormatException();
char coeff[] = new char[len]; // integer significand array
char c; // work
for (; len > 0; offset++, len--) {
c = in[offset];
if ((c >= '0' && c <= '9') || Character.isDigit(c)) {
// have digit
coeff[precision] = c;
precision++; // count of digits
continue;
}
if (c == '.') {
// have dot
if (dotoff >= 0) // two dots
throw new NumberFormatException();
dotoff = offset;
continue;
}
// exponent expected
if ((c != 'e') && (c != 'E'))
throw new NumberFormatException();
offset++;
c = in[offset];
len--;
boolean negexp = false;
// optional sign
if (c == '-' || c == '+') {
negexp = (c == '-');
offset++;
c = in[offset];
len--;
}
if (len <= 0 || len > 10) // no digits, or too long
throw new NumberFormatException();
// c now holds first digit of exponent
for (;; len--) {
int v;
if (c >= '0' && c <= '9') {
v = c - '0';
} else {
v = Character.digit(c, 10);
if (v < 0) // not a digit
throw new NumberFormatException();
}
exp = exp * 10 + v;
if (len == 1)
break; // that was final character
offset++;
c = in[offset];
}
if (negexp) // apply sign
exp = -exp;
// Next test is required for backwards compatibility
if ((int)exp != exp) // overflow
throw new NumberFormatException();
break; // [saves a test]
}
// here when no characters left
if (precision == 0) // no digits found
throw new NumberFormatException();
if (dotoff >= 0) { // had dot; set scale
scale = precision - (dotoff - cfirst);
// [cannot overflow]
}
if (exp != 0) { // had significant exponent
try {
scale = checkScale(-exp + scale); // adjust
} catch (ArithmeticException e) {
throw new NumberFormatException("Scale out of range.");
}
}
// Remove leading zeros from precision (digits count)
int first = 0;
for (; coeff[first] == '0' && precision > 1; first++)
precision--;
// Set the significand ..
// Copy significand to exact-sized array, with sign if
// negative
// Later use: BigInteger(coeff, first, precision) for
// both cases, by allowing an extra char at the front of
// coeff.
char quick[];
if (!isneg) {
quick = new char[precision];
System.arraycopy(coeff, first, quick, 0, precision);
} else {
quick = new char[precision+1];
quick[0] = '-';
System.arraycopy(coeff, first, quick, 1, precision);
}
intVal = new BigInteger(quick);