MCPcopy Create free account
hub / github.com/MCUdude/MicroCore / printNumber

Method printNumber

avr/cores/microcore/Print.cpp:355–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353
354
355size_t Print::printNumber(UNSIGNED_PRINT_INT_TYPE n, uint8_t base)
356{
357 static const char digits[] PROGMEM = "0123456789ABCDEF";
358
359 #if defined(PRINT_USE_BASE_BIN)
360 static const UNSIGNED_PRINT_INT_TYPE base2[] PROGMEM =
361 {
362 #if PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_LONG
363 0x80000000, 0x40000000, 0x20000000, 0x10000000, 0x800000, 0x400000, 0x200000, 0x100000, 0x80000, 0x40000, 0x20000, 0x10000,
364 #endif
365 #if (PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_LONG) || (PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_INT)
366 0x8000, 0x4000, 0x2000, 0x1000, 0x800, 0x400, 0x200, 0x100,
367 #endif
368 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1, 0
369 };
370 #endif
371 #if defined(PRINT_USE_BASE_OCT)
372 static const UNSIGNED_PRINT_INT_TYPE base8[] PROGMEM =
373 {
374 #if PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_LONG
375 010000000000, 01000000000, 0100000000, 010000000, 01000000,
376 #endif
377 #if (PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_LONG) || (PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_INT)
378 0100000, 010000, 01000,
379 #endif
380 0100, 010, 01,
381 0
382 };
383 #endif
384 #if defined(PRINT_USE_BASE_DEC)
385 static const UNSIGNED_PRINT_INT_TYPE base10[] PROGMEM =
386 {
387 #if PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_LONG
388 1000000000,100000000,10000000,1000000,100000,
389 #endif
390 #if (PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_LONG) || (PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_INT)
391 10000, 1000,
392 #endif
393 100, 10, 1,
394 0
395 };
396 #endif
397 #if defined(PRINT_USE_BASE_HEX)
398 static const UNSIGNED_PRINT_INT_TYPE base16[] PROGMEM =
399 {
400 #if PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_LONG
401 0x10000000, 0x1000000,
402 0x100000, 0x010000,
403 #endif
404 #if (PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_LONG) || (PRINT_MAX_INT_TYPE == PRINT_INT_TYPE_INT)
405 0x1000, 0x0100,
406 #endif
407 0x10, 0x01,
408 0
409 };
410 #endif
411
412 UNSIGNED_PRINT_INT_TYPE const * bt;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected