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

Function itoa

src/fl/stl/charconv.cpp.hpp:68–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66// Moved from string_functions namespace in str.cpp for better organization
67
68int itoa(i32 value, char *sp, int radix) {
69 char tmp[16]; // be careful with the length of the buffer
70 char *tp = tmp;
71 int i;
72 u32 v;
73
74 int sign = (radix == 10 && value < 0);
75 if (sign)
76 v = -static_cast<u32>(value);
77 else
78 v = static_cast<u32>(value);
79
80 while (v || tp == tmp) {
81 i = v % radix;
82 v = radix ? v / radix : 0;
83 if (i < 10)
84 *tp++ = i + '0';
85 else
86 *tp++ = i + 'a' - 10;
87 }
88
89 int len = tp - tmp;
90
91 if (sign) {
92 *sp++ = '-';
93 len++;
94 }
95
96 while (tp > tmp)
97 *sp++ = *--tp;
98
99 *sp = '\0'; // Null-terminate the string
100 return len;
101}
102
103int itoa64(i64 value, char *sp, int radix) {
104 char tmp[32]; // Buffer for 64-bit integer (max 65 chars for base 2 + sign)

Callers 7

writeMethod · 0.85
writeMethod · 0.85
appendFormattedMethod · 0.85
ostream.cpp.hppFile · 0.85
printMethod · 0.85
printlnMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected