RF24Log  0.1.3
Unified logging library
Common.cpp
Go to the documentation of this file.
1 
14 #include "Common.h"
15 
16 /****************************************************************************/
17 
18 uint16_t numbCharsToPrint(int64_t numb, uint8_t base)
19 {
20  int64_t mask = (numb < 0 ? numb * -1 : numb);
21  uint16_t i = 0;
22  while (mask)
23  {
24  if (base == 2) { mask >>= 1; }
25  else if (base == 8) { mask >>= 3; }
26  else if (base == 16) { mask >>= 4; }
27  else /*base == 10*/ { mask /= 10; }
28  i++;
29  }
30  if (numb <= 0)
31  {
32  i += 1 + (bool)numb; // compensate for the negative sign (and zero char)
33  }
34  return i;
35 }
uint16_t numbCharsToPrint(int64_t numb, uint8_t base)
how wide (in characters) does it take to display a number
Definition: Common.cpp:18
global functions for RF24Log Abstract objects.