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

Function luaNumber

app/src/DataModel/Importers/ImporterCommon.h:66–73  ·  view source on GitHub ↗

* @brief Returns the value as a Lua number literal with a lossless double round-trip. */

Source from the content-addressed store, hash-verified

64 * @brief Returns the value as a Lua number literal with a lossless double round-trip.
65 */
66[[nodiscard]] inline QString luaNumber(double value)
67{
68 const bool whole = std::isfinite(value) && value == std::floor(value) && std::fabs(value) < 1e15;
69 if (whole)
70 return QString::number(static_cast<qint64>(value));
71
72 return QString::number(value, 'g', 15);
73}
74
75/**
76 * @brief Returns how many decimal places the value's fractional part needs (capped at 4),

Callers 2

buildLuaParserMethod · 0.85
signalSpecLineMethod · 0.85

Calls 3

isfiniteFunction · 0.85
floorFunction · 0.85
fabsFunction · 0.85

Tested by

no test coverage detected