MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / formatNumber

Function formatNumber

app/src/Sessions/HtmlReport.cpp:85–97  ·  view source on GitHub ↗

* @brief Formats a double for tabular display (used in the cell text + the * data-sort-value attribute that drives the sortable table comparator). */

Source from the content-addressed store, hash-verified

83 * data-sort-value attribute that drives the sortable table comparator).
84 */
85static QString formatNumber(double v)
86{
87 if (!std::isfinite(v))
88 // code-verify off
89 return QStringLiteral("—");
90 // code-verify on
91
92 const double abs_v = std::fabs(v);
93 if (abs_v != 0.0 && (abs_v < 1.0e-3 || abs_v >= 1.0e6))
94 return QString::number(v, 'e', 2);
95
96 return QString::number(v, 'f', 3);
97}
98
99/**
100 * @brief Formats a millisecond duration as HH:MM:SS.

Callers 1

buildSummarySectionMethod · 0.85

Calls 2

isfiniteFunction · 0.85
fabsFunction · 0.85

Tested by

no test coverage detected