FastLED 3.9.15
Loading...
Searching...
No Matches

◆ format_float()

fl::string fl::format_detail::format_float ( double value,
const FormatSpec & spec )
inline

Definition at line 249 of file format.h.

249 {
250 int precision = spec.precision >= 0 ? spec.precision : 6;
251
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}
constexpr int type_rank< T >::value
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
void ftoa(float value, char *buffer, int precision)
Convert floating point number to string buffer.

References fl::ftoa(), fl::format_detail::FormatSpec::precision, fl::format_detail::FormatSpec::sign, and fl::type_rank< T >::value.

Referenced by fl::format_detail::FormatArg::format().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: