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