I'd recommend that you use strtod() instead of atof() which can silently fail.