diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index 98eb4fd6ec25f31ae3a4b58cae8f0d9907eeb826..05a1f1882a20d73f242767be9358e79ca3dd9da0 100644 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -188,7 +188,8 @@ size_t Print::println(const Printable& x) // Private Methods ///////////////////////////////////////////////////////////// -size_t Print::printNumber(unsigned long n, uint8_t base) { +size_t Print::printNumber(unsigned long n, uint8_t base) +{ char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. char *str = &buf[sizeof(buf) - 1]; @@ -198,9 +199,9 @@ size_t Print::printNumber(unsigned long n, uint8_t base) { if (base < 2) base = 10; do { - unsigned long m = n; + char c = n % base; n /= base; - char c = m - base * n; + *--str = c < 10 ? c + '0' : c + 'A' - 10; } while(n);