aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortico-tico <sergei.ivn@gmx.com>2016-02-29 15:34:02 +0300
committerSandeep Mistry <s.mistry@arduino.cc>2016-03-03 10:53:25 -0500
commit487bbfde38869de977a095defd6414696744b47d (patch)
treed84307b042f538e999610fb29ac89219c1520552
parent3ba80468d56485f9a078dbd0854b80beaacbcbd4 (diff)
huh? i guess it's just 'modulo'. let's save even more
-rw-r--r--cores/arduino/Print.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp
index bc97c85..5a092af 100644
--- a/cores/arduino/Print.cpp
+++ b/cores/arduino/Print.cpp
@@ -200,7 +200,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];
@@ -210,9 +211,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);