Can I print in binary format?

I have a bitmap that needs to be debugged, and it would be much easier for me to print the number in binary rather than decimal. I can do it?

+3
source share
3 answers

There is a function for printing a binary value in arch/parisc/kernel/traps.c, called printbinary(). You can copy it to your code (or just link it if you are on parisc). It’s better to still move it somewhere common in the kernel tree, for example. liband send the patch to LKML.

+4
source

Maybe try hex or octal:

printk("%02X", mybyte);
printk("%03o", mybyte);
+6
source

printk sprintf, , printf. , . , . .

+1
source

Source: https://habr.com/ru/post/1777848/


All Articles