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

Function fastPow10

app/src/UI/Widgets/Waterfall.cpp:93–105  ·  view source on GitHub ↗

* @brief Integer-exponent 10^n via table lookup; falls back to std::pow if out of band. */

Source from the content-addressed store, hash-verified

91 * @brief Integer-exponent 10^n via table lookup; falls back to std::pow if out of band.
92 */
93static inline double fastPow10(double exponent) noexcept
94{
95 static constexpr double kTable[] = {
96 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5,
97 1e-4, 1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6,
98 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
99 };
100 const int idx = static_cast<int>(exponent) + 15;
101 if (idx < 0 || idx >= static_cast<int>(sizeof(kTable) / sizeof(kTable[0]))) [[unlikely]]
102 return std::pow(10.0, exponent);
103
104 return kTable[idx];
105}
106
107/**
108 * @brief Linearly interpolates a color from per-channel LUT arrays of length n.

Callers 1

computeFreqTicksMethod · 0.70

Calls 1

powFunction · 0.85

Tested by

no test coverage detected