| 33 | } |
| 34 | |
| 35 | bool is_float(const std::string& str) |
| 36 | { |
| 37 | std::string float_str = str; |
| 38 | bool is_a_float = false; |
| 39 | if (!float_str.empty()) |
| 40 | { |
| 41 | if (float_str.substr(0, 1) == "-") |
| 42 | float_str = float_str.substr(1); |
| 43 | if (count(float_str, ".") == 1) |
| 44 | { |
| 45 | is_a_float = true; |
| 46 | float_str.erase(float_str.find('.')); |
| 47 | } |
| 48 | return ( |
| 49 | std::all_of(float_str.begin(), float_str.end(), is_digit) && is_a_float); |
| 50 | } |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | std::string truncate_float(const std::string& str) |
| 55 | { |