Binary to decimal using bitwise operators I am trying to convert some binary data to decimal numbers. I succeeded to convert binary to hex, but now I want to do the same with binary to decimal. I want to use bitwise operators and NO array.

See my code from binairy to hex. The incoming data is 8 bits. This code first calculates the most significant number, and then, the least significant number. This works good, but I cannot figure it out for bin to dec

The function console_print_char is sort of the printf function of my program.

    void console_print_hex_char(unsigned char data){
    unsigned char temp;

    if(data){
        temp = (data &gt;&gt; 4);
        if(temp){
            if(temp&gt; 9) console_print_char(temp + ('A'- 10));
            else console_print_char(temp + '0');
        }
        temp = data &amp; 0x0F;
        if(temp&gt; 9) console_print_char(temp + ('A'- 10));
        else console_print_char(temp + '0');
    }
    else{
        console_print_char('0');
    }
}
You cannot do what you are trying to do. There is no direct correspondence between some number of bits and a decimal digit.

With hexadecimal, every 4 bits corresponds to exactly 1 hex digit. That is why hex is used for computers.

One hex digit represents exactly 4 bits. Every time you add another hex digit, you add 4 bits. 

Two hex digits corresponds to exactly a byte. 00h to FFh represents a value from 0 to 255.

There is no such direct correspondence between binary and decimal. If you have 4 bits, it takes 1 or 2 decimal digits to represent it (0-15) If you have 8 bits, it takes 1, 2, or 3 decimal digits to represent it, but there are 3 digit decimal values (values > 255) that you can't represent with 8 bits. 

Binary  Hex Decimal
0000    0   0
0001    1   1
0010    2   2
0011    3   3
0100    4   4
0101    5   5
0110    6   6
0111    7   7
1000    8   8
1001    9   9
1010    A   10
1011    B   11
1100    C   12
1101    D   13
1110    E   14
1111    F   15


You simply cannot convert a binary number to decimal using bit shifting and masking. 

As @Kwasmich says in their answer, the closest you're likely to come would be to convert your binary value to BCD (Binary coded decimal) where each 4 bits holds a decimal digit. You could convert THAT to decimal character output using masking and shifting.