Skip to content

Commit 7e1d891

Browse files
committed
Revert to explicit calculation of modulo, saving 16 bytes in IROM.
1 parent af53772 commit 7e1d891

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cores/esp8266/Print.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,9 @@ size_t Print::printNumber(unsigned long n, uint8_t base) {
280280
base = 10;
281281

282282
do {
283-
char c = n % base;
283+
unsigned long m = n;
284284
n /= base;
285+
char c = m - base * n;
285286

286287
*--str = c < 10 ? c + '0' : c + 'A' - 10;
287288
} while(n);
@@ -300,8 +301,9 @@ size_t Print::printNumber(unsigned long long n, uint8_t base) {
300301
base = 10;
301302

302303
do {
303-
char c = n % base;
304+
unsigned long m = n;
304305
n /= base;
306+
char c = m - base * n;
305307

306308
*--str = c < 10 ? c + '0' : c + 'A' - 10;
307309
} while(n);

0 commit comments

Comments
 (0)