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

◆ utoa32()

int fl::utoa32 ( u32 value,
char * buffer,
int radix )

Convert unsigned 32-bit integer to string buffer in given radix.

Parameters
valueThe unsigned integer value to convert
bufferOutput buffer (must be at least 33 bytes for base 2, 11 for base 10, 9 for base 16)
radixNumber base (2-36, typically 10 for decimal, 16 for hex, 8 for octal)
Returns
Number of characters written (excluding null terminator)

Definition at line 138 of file charconv.cpp.hpp.

138 {
139 char tmp[16]; // be careful with the length of the buffer
140 char *tp = tmp;
141 int i;
142 u32 v = value;
143
144 while (v || tp == tmp) {
145 i = v % radix;
146 v = radix ? v / radix : 0;
147 if (i < 10)
148 *tp++ = i + '0';
149 else
150 *tp++ = i + 'a' - 10;
151 }
152
153 int len = tp - tmp;
154
155 while (tp > tmp)
156 *sp++ = *--tp;
157
158 *sp = '\0'; // Null-terminate the string
159 return len;
160}
constexpr int type_rank< T >::value

References type_rank< T >::value.

Referenced by fl::sstream::appendFormatted(), fl::basic_string::appendHex(), fl::basic_string::appendOct(), fl::ostream::operator<<(), fl::ostream::operator<<(), fl::basic_string::write(), fl::basic_string::write(), and fl::basic_string::write().

+ Here is the caller graph for this function: