1.6 Representation of numbers: Binary and hexadecimal

For any counting system, each individual digit of a given number represents a value according to its position relative to the unit position10 and according to the base underlying the respective system:

 \begin{equation*} \begin{array}{rlcl} 147.35_{10}&=1\times10^2+4\times10^1+7\times10^0+3\times10^{-1}+5\times10^{-2}& &\text{--- decimal system;}\\ \rule{0mm}{0.7em} 101.01_2 &=1\times2^2+0\times2^1+1\times2^0+0\times2^{-1}+1\times2^{-2}& &\text{--- binary system.} \end{array} \end{equation*}(1.1)

The conversion from integer decimal to binary numbers is done by repeated division by 2. The remainder of this division, which is either 0 or 1, successively provides the digits of the binary number (from right to left). As an example it is shown how to convert the decimal value 6 to the binary system:

 \begin{equation*} \begin{array}{lcccc} &\textbf{/2}&\textbf{result}&\textbf{remainder}&\textbf{total} \\ \hline 6_{10}& /2 & 3 & 0 & \\ 3 & /2 & 1 & 1 & \\ 1 & /2 & 0 & 1 &\Rightarrow110_2 \end{array} \end{equation*}(1.2)

The conversion of fractional decimal to fractional binary numbers smaller than 1 is done by repeated multiplication by 2. The value at the decimal point, which is either 0 or 1, is the next binary digit (from left to right), and the remaining fraction is further multiplied by 2. This is shown as an example for the decimal value 3/8:

 \begin{equation*} \begin{array}{lccccc} &\mathbf{\times2}&\textbf{result}&\textbf{at\,dec.\,point}&\textbf{remaining}&\textbf{total} \\ \hline 0.375_{10}& \times2 & 0.75 & 0 & .75 & \\ 0.75 & \times2 & 1.5 & 1 & .5 & \\ 0.5 & \times2 & 1.0 & 1 & .0 &\Rightarrow0.011_2 \end{array} \end{equation*}(1.3)

As in the decimal system, an integer exponent \(n\gt 0\) tells the number of trailing zeros of \(2^n\) (or, equivalently, the number of places of the next-smallest integer):

 \begin{equation*} 2^n=\underbrace{1000...0}_{n+1\text{ places}}\,,\quad 2^n-1=\underbrace{111...1}_{n\text{ places}}\,. \label{eq:numberofplaces1} \end{equation*}(1.4)

On the other hand, an integer exponent \(n\lt0\) tells the number of leading zeros of \(2^n\) up to the unit position (or, equivalently, the number of nonzero places of \(1-2^n\)):

 \begin{equation*} 2^{-|n|}=\underbrace{0.00...01}_{|n|+1\text{ places}}\,,\quad 1-2^{-|n|}=0.\!\underbrace{11...11}_{|n|\text{ places}}\,. \label{eq:numberofplaces2} \end{equation*}(1.5)

In the hexadecimal system (abbreviated as “hex”), the base 16 is used. Therefore, at each place of a number, values between zero and fifteen can occur. In this system, the letters A through F serve as signs to denote the values ten through fifteen. The hexadecimal digits therefore are: 0, 1, 2, ..., 9, A, B, C, D, E, F. Example:

 \begin{equation*} 17\text{F}_{\text{hex}} = (1\times16^2+7\times16^1+15\times16^0)_{10} = 383_{10}\,. \end{equation*}(1.6)

10For integer numbers, the unit position is the last digit to the right; for fractional numbers it is the one left of the (respective) point.


With frame Back Forward as PDF

© J. Carstensen (Comp. Math.)