Binary Conversion Notes

These notes include more information than is needed for MGF 1107.

MGF 1107 students can ignore everything about binary fractions, the binary version of scientific notation, and hexadecimal numbers when reading what follows. We only use binary integers in MGF 1107.

Web links on using binary numbers

Binary to Decimal Conversion

This is done by applying the definition of the place values for a binary number, evaluating each one in base ten. For example, we convert 1001two from binary to decimal as follows:

        1*8 + 0*4 + 0*2 + 1*1 = 8 + 0 + 0 + 1
which is 9ten. Most people find this to be the easiest of the two conversions.

Fractions are handled with negative exponents for each fractional place value, just as with decimal numbers, so we convert 0.11two from binary to decimal by recognizing that

          1*(1/2) + 1*(1/4) = 0.5 + 0.25
gives 0.75ten. MGF 1107 homework does not include examples with binary fractions.

Decimal to Binary Conversion

The integer part is obtained (working from right to left) by repeated division by two (which shifts the binary-point to the left), keeping the remainder as the next binary digit and using the integer quotient for the next step. We stop when the quotient is zero. (The easiest way to get the integer part is to use the Hex conversion feature of a calculator and convert hexadecimal to binary, but we are not using calculators in this unit.)

The fractional part is obtained (now working from left to right) by repeated multiplication by two (which shifts the binary-point to the right), keeping the integer part as the next binary digit and using the fractional part for the next step. There are no easy shortcuts for the fractional part, but watch for any repeating pattern.

We can write the result as a normalized floating-point binary number with the convention that the mantissa (the significand) is between 1 and 2 -- that is, the mantissa is of the form 1.ffffff.

Examples:

1. Convert 11ten to binary:
The integer is converted by

    11 / 2 = 5 r 1   (1) in "ones" place
     5 / 2 = 2 r 1   (1)
     2 / 2 = 1 r 0   (0)
     1 / 2 = 0 r 1   (1)
and is 1011two.
(This is 1.011 x 23 as a normalized floating-point number.)

2. Convert 5.75ten to binary:
The integer part is found by

       5 / 2 = 2 r 1   (1) in "ones" place
       2 / 2 = 1 r 0   (0)
       1 / 2 = 0 r 1   (1)
and is 101two.
The fractional part is found by
    0.75 x 2 = 1.5  (1)
    0.5  x 2 = 1.0  (1)
     0   x 2 =  0   (0) so it terminates
so the number is 101.11two.
(This is 1.0111 x 22 as a normalized floating-point number.)

3. Convert 0.1ten to binary:
The fractional part is found by

    0.1 x 2 = 0.2  (0)
    0.2 x 2 = 0.4  (0)
    0.4 x 2 = 0.8  (0)
    0.8 x 2 = 1.6  (1)
    0.6 x 2 = 1.2  (1)
    0.2 x 2 = 0.4  (0) which repeats 0.2 above ... 
    0.4 x 2 = 0.8  (0) etc ... 
    0.8 x 2 = 1.6  (1) etc ... 
so the number is 0.0001100110011....two
(This is 1.10011001.... x 2-4 as a normalized floating-point number.)

Hexadecimal Numbers

Decimal - Hexadecimal - Binary Table

     0     1     2     3     4     5     6     7     (decimal) 
     0     1     2     3     4     5     6     7   (hexadecimal) 
     0     1    10    11   100   101   110   111     (binary) 

     8     9    10    11    12    13    14    15     (decimal)
     8     9     A     B     C     D     E     F   (hexadecimal)
  1000  1001  1010  1011  1100  1101  1110  1111     (binary)

    16    17     ....    (decimal)
    10    11     ....  (hexadecimal)
 10000 10001     ....    (binary) 

Historical note:

Way back in the 1950s, the ILLIAC was built at the University of Illinois (Urbana-Champaign) using the "sexadecimal" number system. However, they counted ... 8, 9, K, S, N, J, F, L instead of using ... 8, 9, A, B, C, D, E, F as we do today. They chose those letters (which were remembered using the mnemonic King Sized Numbers Just For Laughs) because they proved the most convenient ones when they converted a teletype to be used for punching the paper tape used for I/O. (This info from J. Sutherland Frame, professor emeritus of Mathematics at Michigan State University, an early programmer of the 1957 clone of the ILLIAC known as MISTIC, both of which are in the ORDVAC family of computers.)

(An aside: Fans of "2001: A Space Odyssey" will recall that the HAL-9000 computer was built in Champaign-Urbana. This reflects the historic role the Univ. of Illinois had in the early development of computers with the construction of the ILLIAC. In addition, although Everyone knows that HAL is rot25 of IBM, the serial number reflects the sequence used by Control Data, whose 6000 series machines were the supercomputer in the mid-60s when "2001" was made. The Cray-1 would have been an 8000 series machine, but CDC chose the "Star" design that led to the Cyber-205 and Cray formed his own company. Kubrick guessed about right in placing a 9000 series machine that could talk in the early 90s - HAL was born on 1/12/92 - but someone forgot the mouse.)

This material is © Copyright 2000, by James Carr.