double
atof(cp)
register char *cp;
{
	double acc;
	char msign, esign, dpflg;
	int i, dexp;

	if (*cp == '-') {
		++cp;
		msign = 1;
	} else {
		msign = 0;
		if (*cp == '+')
			++cp;
	}

	dpflg = dexp = 0;
	for (acc = 0 ; ; ++cp) {
		if (isdigit(*cp)) {
			acc *= 10;
			acc += *cp - '0';
			if (dpflg)
				--dexp;
		} else if (*cp == '.') {
			if (dpflg)
				break;
			dpflg = 1;
		} else
			break;
	}

	if (*cp == 'e' || *cp == 'E') {
		++cp;
		if (*cp == '-') {
			++cp;
			esign = 1;
		} else {
			esign = 0;
			if (*cp == '+')
				++cp;
		}
		for ( i = 0 ; isdigit(*cp) ; i = i*10 + *cp++ - '0' )
			;
		if (esign)
			i = -i;
		dexp += i;
	}

	if (dexp < 0) {
		while (dexp++)
			acc /= 10;
	} else if (dexp > 0) {
		while (dexp--)
			acc *= 10;
	}

	if (msign)
		acc = -acc;
	return acc;
}
