22 lines
368 B
C
22 lines
368 B
C
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include "ucore/string.h"
|
|
|
|
char*
|
|
uc_sprintbc(char *result, unsigned char value)
|
|
{
|
|
char *s = result;
|
|
unsigned char mask = ~((unsigned char) (~0U) >> 1U);
|
|
|
|
if (s) {
|
|
while (mask) {
|
|
*s++ = (mask & value) ? '1' : '0';
|
|
mask >>= 1U;
|
|
}
|
|
*s = '\0';
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|