Mantid
Loading...
Searching...
No Matches
FormattingHelpers.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2026 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
9#include <cmath>
10#include <iomanip>
11#include <sstream>
12
13namespace Mantid::DataHandling {
14
15std::string formatDouble(double const value) {
16 std::stringstream ss;
17 if (std::fabs(value - std::round(value)) < 1e-12) {
18 ss << std::fixed << std::setprecision(1) << value;
19 } else {
20 ss << value;
21 }
22 return ss.str();
23}
24
25} // namespace Mantid::DataHandling
double value
The value of the point.
Definition FitMW.cpp:51
MANTID_DATAHANDLING_DLL std::string formatDouble(double const value)