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

◆ itoa64()

int fl::itoa64 ( i64 value,
char * buffer,
int radix )

Convert signed 64-bit integer to string buffer in given radix.

Parameters
valueThe signed 64-bit integer value to convert
bufferOutput buffer (must be at least 66 bytes for base 2 with sign, 21 for base 10)
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 103 of file charconv.cpp.hpp.

103 {
104 char tmp[32]; // Buffer for 64-bit integer (max 65 chars for base 2 + sign)
105 char *tp = tmp;
106 int i;
107 u64 v;
108
109 int sign = (radix == 10 && value < 0);
110 if (sign)
111 v = -static_cast<u64>(value);
112 else
113 v = static_cast<u64>(value);
114
115 while (v || tp == tmp) {
116 i = v % radix;
117 v = radix ? v / radix : 0;
118 if (i < 10)
119 *tp++ = i + '0';
120 else
121 *tp++ = i + 'a' - 10;
122 }
123
124 int len = tp - tmp;
125
126 if (sign) {
127 *sp++ = '-';
128 len++;
129 }
130
131 while (tp > tmp)
132 *sp++ = *--tp;
133
134 *sp = '\0'; // Null-terminate the string
135 return len;
136}
constexpr int type_rank< T >::value
constexpr enable_if< is_fixed_point< T >::value, int >::type sign(T x) FL_NOEXCEPT
fl::u64 u64
Definition s16x16x4.h:221

References sign(), and type_rank< T >::value.

Referenced by fl::basic_string::appendHex(), fl::basic_string::appendOct(), fl::SerialPort::print(), and fl::SerialPort::println().

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