Skip to content

Commit a7454b6

Browse files
committed
huh? i guess it's just 'modulo'. let's save even more
1 parent 275a47d commit a7454b6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hardware/arduino/avr/cores/arduino/Print.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ size_t Print::println(const Printable& x)
200200

201201
// Private Methods /////////////////////////////////////////////////////////////
202202

203-
size_t Print::printNumber(unsigned long n, uint8_t base) {
203+
size_t Print::printNumber(unsigned long n, uint8_t base)
204+
{
204205
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
205206
char *str = &buf[sizeof(buf) - 1];
206207

@@ -210,9 +211,9 @@ size_t Print::printNumber(unsigned long n, uint8_t base) {
210211
if (base < 2) base = 10;
211212

212213
do {
213-
unsigned long m = n;
214+
char c = n % base;
214215
n /= base;
215-
char c = m - base * n;
216+
216217
*--str = c < 10 ? c + '0' : c + 'A' - 10;
217218
} while(n);
218219

0 commit comments

Comments
 (0)