float stringToFloat (string s) { for (unsigned int i = 0; i < s.length (); i++) if (!isdigit (s[i]) && (s[i] != '.') && (s[i] != ',') && (s[i] != '+') && (s[i] != '-')) throw BadInput ((std::string ("Cannot convert character: ") + s[i] + " in " + s).c_str ()); stringstream fss; fss << s; float f; fss >> f; return f; } string floatToString (float f) { std::ostringstream buf; buf.precision (2); buf << fixed << f; return buf.str (); }