kandr

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 4948fa51e1f3d1f38cb2b7b83911692ca0bd4d43
parent 329d084f34662e023b1be9014118693bfb4ea5a9
Author: phoebos <ben@bvnf.space>
Date:   Sun, 11 Jul 2021 20:51:04 +0100

function to print chars in binary format for debugging

Diffstat:
Aprintf_binary.c | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/printf_binary.c 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; + } +}