We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
arduino
Learn more about funding links in repositories.
Report abuse
There was an error while loading. Please reload this page.
1 parent 0428ad8 commit 8e67a64Copy full SHA for 8e67a64
cores/arduino/Print.cpp
@@ -202,10 +202,7 @@ size_t Print::println(const Printable& x)
202
203
size_t Print::printNumber(unsigned long n, uint8_t base)
204
{
205
- char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
206
- char *str = &buf[sizeof(buf) - 1];
207
-
208
- *str = '\0';
+ size_t written = 0;
209
210
// prevent crash if called with base == 1
211
if (base < 2) base = 10;
@@ -214,10 +211,11 @@ size_t Print::printNumber(unsigned long n, uint8_t base)
214
char c = n % base;
215
212
n /= base;
216
213
217
- *--str = c < 10 ? c + '0' : c + 'A' - 10;
+ c = (c < 10 ? c + '0' : c + 'A' - 10);
+ written += write(&c, 1);
218
} while(n);
219
220
- return write(str);
+ return written;
221
}
222
223
size_t Print::printFloat(double number, uint8_t digits)
0 commit comments