/****************************************************************************** * This program computes the sum of a list of float values on STDIN. * * Copyright © 2016 Richard Lesh. All rights reserved. *****************************************************************************/ #undef NDEBUG #include "Utils.hpp" #include #include #include using namespace Utils; using namespace std; int main(int argc, char **argv) { string line; double d; double total = 0; while (getline(cin, line)) { line = Utils::trim(line); try { d = stod(line); total += d; } catch (...) { if (line.length() > 0) { cout << "Can't parse input: " << line << endl; } } } cout << fmt::format("{0:g}", total) << endl; return 0; }