How it works...

The first step is to convert the binary number into a decimal number. To do so, we will separate all the binary digits and multiply each by 2 raised to the power of their position in the binary number. We will then apply the mod 10 operator in order to separate the binary number into individual digits. Every time mod 10 is applied to the binary number, its last digit is separated and then pushed to the stack.

Let's assume that the binary number that we need to convert into a hexadecimal format is 110001. We will apply the mod 10 operator to this binary number. The mod operator divides the number and returns the remainder. On application of the mod 10 operator, the last binary digit—in other words the rightmost digit will be ...

Get Practical C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.