fix index
This commit is contained in:
parent
545b0be96e
commit
3c4a1ae976
8
global.c
8
global.c
|
@ -35,8 +35,8 @@ volatile bool button_flag = false;
|
|||
char* b2s(uint64_t binary, uint8_t rjust)
|
||||
{
|
||||
static char string[64+1] = {0}; // the string representation to return
|
||||
int8_t bit = LENGTH(string)-1; // the index of the bit to print
|
||||
string[bit--] = 0; // terminate string
|
||||
uint8_t bit = LENGTH(string)-1; // the index of the bit to print
|
||||
string[bit--] = '\0'; // terminate string
|
||||
|
||||
while (binary) {
|
||||
if (binary & 1) {
|
||||
|
@ -47,11 +47,11 @@ char* b2s(uint64_t binary, uint8_t rjust)
|
|||
binary >>= 1;
|
||||
}
|
||||
|
||||
while (64-bit-1<rjust && bit>=0) {
|
||||
while (64-bit-1<rjust && bit>0) {
|
||||
string[bit--] = '0';
|
||||
}
|
||||
|
||||
return &string[bit+1];
|
||||
return string;
|
||||
}
|
||||
|
||||
/** switch on board LED */
|
||||
|
|
Loading…
Reference in New Issue