atoi (with validation)