# Penning Trap Simulation: src/utils.cpp Source File

Loading...
Searching...
No Matches
utils.cpp
Go to the documentation of this file.
#include "utils.hpp"
std::string scientific_format(double d, int width, int prec)
{
std::stringstream ss;
ss << std::setw(width) << std::setprecision(prec) << std::scientific << d;
return ss.str();
}
std::string scientific_format(const std::vector<double>& v, int width, int prec)
{
std::stringstream ss;
for(double elem : v) {
ss << scientific_format(elem, width, prec);
}
return ss.str();
}
scientific_format
std::string scientific_format(double d, int width, int prec)
Turns a double into a string written in scientific format.
Definition: utils.cpp:14
utils.hpp
Function prototypes and macros that are useful.