File tree 1 file changed +10
-8
lines changed
1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -270,43 +270,45 @@ size_t Print::println(const Printable& x) {
270
270
// Private Methods /////////////////////////////////////////////////////////////
271
271
272
272
size_t Print::printNumber (unsigned long n, uint8_t base) {
273
- char buf[8 * sizeof (long ) + 1 ]; // Assumes 8-bit chars plus zero byte.
273
+ char buf[8 * sizeof (n ) + 1 ]; // Assumes 8-bit chars plus zero byte.
274
274
char *str = &buf[sizeof (buf) - 1 ];
275
275
276
276
*str = ' \0 ' ;
277
277
278
278
// prevent crash if called with base == 1
279
- if (base < 2 )
279
+ if (base < 2 ) {
280
280
base = 10 ;
281
+ }
281
282
282
283
do {
283
- unsigned long m = n;
284
+ auto m = n;
284
285
n /= base;
285
286
char c = m - base * n;
286
287
287
288
*--str = c < 10 ? c + ' 0' : c + ' A' - 10 ;
288
- } while (n);
289
+ } while (n);
289
290
290
291
return write (str);
291
292
}
292
293
293
294
size_t Print::printNumber (unsigned long long n, uint8_t base) {
294
- char buf[8 * sizeof (long long ) + 1 ]; // Assumes 8-bit chars plus zero byte.
295
+ char buf[8 * sizeof (n ) + 1 ]; // Assumes 8-bit chars plus zero byte.
295
296
char * str = &buf[sizeof (buf) - 1 ];
296
297
297
298
*str = ' \0 ' ;
298
299
299
300
// prevent crash if called with base == 1
300
- if (base < 2 )
301
+ if (base < 2 ) {
301
302
base = 10 ;
303
+ }
302
304
303
305
do {
304
- unsigned long m = n;
306
+ auto m = n;
305
307
n /= base;
306
308
char c = m - base * n;
307
309
308
310
*--str = c < 10 ? c + ' 0' : c + ' A' - 10 ;
309
- } while (n);
311
+ } while (n);
310
312
311
313
return write (str);
312
314
}
You can’t perform that action at this time.
0 commit comments