18/01/06 19:03:18.86 KWkl+TbG.net
>>186
class C {
private static final Pattern p = Pattern.compile("^(\\-?(0|[1-9]\\d*)(\\.\\d+)?((e|E)(\\+|\\-)?\\d+)?)");
public static int atoi(String s) {
return toDouble(s).intValue();
}
public static double atof(String s) {
return toDouble(s);
}
private static Double toDouble(String s) {
Matcher m = p.matcher(s);
if (!m.find()) {
return new Double(0);
}
return new Double(m.group(1));
}
}