Numbering System Basics
C2000 Microcontroller Workshop - Numerical Concepts 8 - 3
Numbering System Basics
Given the ability to perform arithmetic processes (addition and multiplication) with the C28x, it is
important to understand the underlying mathematical issues which come into play. Therefore, we
shall examine the numerical concepts which apply to the C28x and, to a large degree, most
processors.
Binary Numbers
The binary numbering system is the simplest numbering scheme used in computers, and is the
basis for other schemes. Some details about this system are:
• It uses only two values: 1 and 0
• Each binary digit, commonly referred to as a bit, is one “place” in a binary number
and represents an increasing power of 2.
• The least significant bit (LSB) is to the right and has the value of 1.
• Values are represented by setting the appropriate 1's in the binary number.
• The number of bits used determines how large a number may be represented.
Examples:
0110
2
= (0 * 8) + (1 * 4) + (1 * 2) + (0 * 1) = 6
10
11110
2
= (1 * 16) + (1 * 8) + (1 * 4) + (1 * 2) + (0 * 1) = 30
10
Two's Complement Numbers
Notice that binary numbers can only represent positive numbers. Often it is desirable to be able to
represent both positive and negative numbers. The two's complement numbering system modifies
the binary system to include negative numbers by making the most significant bit (MSB)
negative. Thus, two's complement numbers:
• Follow the binary progression of simple binary except that the MSB is negative — in
addition to its magnitude
• Can have any number of bits — more bits allow larger numbers to be represented
Examples:
0110
2
= (0 * -8) + (1 * 4) + (1 * 2) + (0 * 1) = 6
10
11110
2
= (1 * -16) + (1 * 8) + (1 * 4) + (1 * 2) + (0 * 1) = -2
10
The same binary values are used in these examples for two's complement as were used above for
binary. Notice that the decimal value is the same when the MSB is 0, but the decimal value is
quite different when the MSB is 1.
Two operations are useful in working with two's complement numbers:
• The ability to obtain an additive inverse of a value
• The ability to load small numbers into larger registers (by sign extending)