From f42d61dee96205c888a240e9a510f1e5a40e6a6f Mon Sep 17 00:00:00 2001 From: Lorenzo Rovigatti Date: Tue, 17 Sep 2024 14:03:15 +0200 Subject: [PATCH] Make it possible to print the kinetic and total energies with any precision --- src/Observables/KineticEnergy.cpp | 2 +- src/Observables/TotalEnergy.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Observables/KineticEnergy.cpp b/src/Observables/KineticEnergy.cpp index 876d9083f..8fd7a9c76 100644 --- a/src/Observables/KineticEnergy.cpp +++ b/src/Observables/KineticEnergy.cpp @@ -52,5 +52,5 @@ number KineticEnergy::get_kinetic_energy() { std::string KineticEnergy::get_output_string(llint curr_step) { number K = get_kinetic_energy(); - return Utils::sformat("% 10.6lf", K); + return Utils::sformat(_number_formatter, K); } diff --git a/src/Observables/TotalEnergy.cpp b/src/Observables/TotalEnergy.cpp index b3d4e6ee2..df6fc8e21 100644 --- a/src/Observables/TotalEnergy.cpp +++ b/src/Observables/TotalEnergy.cpp @@ -33,7 +33,8 @@ std::string TotalEnergy::get_output_string(llint curr_step) { number U = get_U(curr_step); number K = get_K(curr_step); - return Utils::sformat("% 10.6lf % 10.6lf % 10.6lf", U, K, U + K); + std::string format = Utils::sformat("%s %s %s", _number_formatter.c_str(), _number_formatter.c_str(), _number_formatter.c_str()); + return Utils::sformat(format, U, K, U + K); } number TotalEnergy::get_U(llint curr_step) {