MCPcopy Create free account
hub / github.com/FastLED/FastLED / format_float

Function format_float

src/fl/stl/format.h:249–270  ·  view source on GitHub ↗

Format a floating point value

Source from the content-addressed store, hash-verified

247
248// Format a floating point value
249inline fl::string format_float(double value, const FormatSpec& spec) {
250 int precision = spec.precision >= 0 ? spec.precision : 6;
251
252 fl::string result;
253
254 // Handle sign
255 if (value < 0) {
256 result.append('-');
257 value = -value;
258 } else if (spec.sign == '+') {
259 result.append('+');
260 } else if (spec.sign == ' ') {
261 result.append(' ');
262 }
263
264 // Format the number
265 char buf[64];
266 fl::ftoa(static_cast<float>(value), buf, precision);
267 result.append(buf);
268
269 return result;
270}
271
272// Format a pointer
273inline fl::string format_pointer(const void* ptr, const FormatSpec& spec) {

Callers 1

formatMethod · 0.70

Calls 2

ftoaFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected