diff options
-rw-r--r-- | printf_binary.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/printf_binary.c b/printf_binary.c new file mode 100644 index 0000000..b36dcc9 --- /dev/null +++ b/printf_binary.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +void bp(char n){ + /* prints chars up to value 255 (for 255, the MSB is 2^7 == 128) */ + int i = 128; + while (i) { + printf("%c", ((n & i) == i) ? '1' : '0'); + i >>= 1; + } +} |