NUMBERING  SYSTEMS

Definition
A numbering system is a scheme for counting or calculating using symbols to represent values.

General Rules for Numbering Systems

1. The BASE of a numbering system is equal to the number of symbols used in the numbering system.

2. The SYMBOLS used represent the values 0 through the base - 1.

3. POSITION VALUES are, from right to left, 1, 1 x base, 1 x base x base, 1 x base x base x base, etc.

4. NUMERIC VALUE is equal to the sum of the symbol in each position times its respective position value.

Decimal Numbering System
This is the numbering system that is the most familiar to us.

Characteristics
BASE = 10
SYMBOLS = 0 through 9
  
                 POSITION VALUES = 1 x 100 = 1

1 x 101 = 10

1 x 102 = 100

1 x 103 = 1000

1 x 104 = 10000

Any decimal value can be expressed by the sum of the products of the coefficients (the digits 0 through 9) and the weighting factors (powers of 10).

Example

1983 in base 10 is:

1000 + 900 + 80 + 3

= 1 x 103 + 9 x 102 + 8 x 101 + 3 x 100
  
                 |        |
  
                 |        |-----> weighting factor
  
                 |---------> coefficient


Binary Numbering System
All computer systems are built as binary systems. Data is stored in main computer storage as a series of bits being "on" or "off", symbolically represented as a "1" or "0".

Characteristics

BASE = 2
SYMBOLS = 0 and 1
POSITION VALUES = 1 x 20 = 1

1 x 21 = 2

1 x 22 = 4

1 x 23 = 8

1 x 24 = 16

1 x 25 = 32

1 x 26 = 64

1 x 27 = 128

1 x 28 = 256

Alternative way of representing position values

Position Values

  256 128 64 32 16 8 4 2 1 Decimal Values
Binary 0 0 0 1 0 1 0 1 1 43
Number 0 1 0 0 1 0 1 0 1 14


Binary to Decimal Conversion

Conventions used: A pair of parentheses () is used to surround the number. The subscript value indicates the base. If no () is present, base 10 is assumed.

The decimal value is obtained by expanding digits in the number by increasing powers of two as one moves away from the decimal point.

Example:

(11010)2
|||||-------> 0 x 20 = 0 x 0  = 0
||||--------> 1 x 21 = 1 x 2  = 2
|||---------> 0 x 22 = 0 x 4  = 0
||----------> 1 x 23 = 1 x 8  = 8
|-----------> 1 x 24 = 1 x 16 = 16
   
                  Sum of products = (26)10

 

Hexadecimal Numbering System

Characteristics
BASE = 16
SYMBOLS = 0 through 9, A through F
POSITION VALUES = 1 x 160 = 1

                                        1 x 161 = 16

                                        1 x 162 = 256

                                        1 x 163 = 4096

In the hexadecimal system, hexadecimal digits can take on values from 0 through 15. But, we must have one digit symbol for the numbers ten through fifteen such as those used for the numbers zero through nine. Thus, the alphabetic characters A through F were selected to represent those values. The letter A represents 10, B represents 11, C is 12, D is 13, E is 14, and F is 15.

The hexadecimal numbering system is often used because, although all computers function as binary machines, it is too cumbersome to try to interpret binary strings. Decimal numbers are not typically used for viewing the internal contents of computer memory because binary to decimal conversions are relatively slow and can be inexact with fractional numbers.

The hexadecimal numbering system solves both problems. It is much more concise than binary and provides direct and exact conversion to and from binary (i.e., 4 binary digits equal exactly one hexadecimal digit).

Example

(12AB)16
 
||||-----> B x 160 = 11 X 1   = 11
  |||------> A x 161 = 10 X 16  = 160
  ||-------> 2 x 162 = 2 X 256  = 512
  |--------> 1 x 163 = 1 X 4096 = 4096
  
                      Sum of products = (4779)10

Binary and Hexadecimal equivalents for the decimal values 1 through 16

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


Examples

(67)10 = (01000011)2 = (43)16

(255)10 = (11111111)2 = (FF)16

(256)10 = (100000000)2 = (100)16

Binary to Hexadecimal conversion steps

(1) Starting from the right, separate the binary number into four digit segments. Supply high order zeros if necessary.

(2) Convert each four digit binary segment to its hexadecimal equivalent.

Additional explanation

Since 24 = 16, there are exactly four binary digits to one hexadecimal digit. Take the binary number and divide it into groups of four digits. To convert, begin at the binary point and work right to left.

Example

(10110110)2 = (??)16

The two groups of four binary numbers are: 1101 and 0110

Take each group of 4 binary digits & mentally convert to hexadecimal.

Thus: (0110)2  = (6)10  = (6)16  and
          (1011)
2 = (11)10 = (B)16

and the answer is B6 in hexadecimal.

 

Hexadecimal to Binary conversion steps:

(1) Convert each hexadecimal digit to its four digit binary equivalent.

Example

(AF37)16 = (?????)2

 ( A   F    3    7 )16
  
|    |    |    |
(1010 1111 0011 0111)2

 

Magnitude

The magnitude of a number is always restricted by 2N - 1 where N is the number of bits within the registers or memory cell where the number is being stored.

Stated another way, the largest number a register (memory location or address) can contain can be stated by using the number of bits as a power of 2 and subtracting 1.

Format:

2N - 1                  N = number of bits

Example

8 bit address: 28 - 1  =  256 - 1  =  255

The largest decimal value that can be contained in an 8 bit memory location is 255.

 

Signed Binary Numbers

We have seen how to represent positive binary numbers. We also need a way to represent negative binary numbers. One way to represent negative binary numbers is to take what is called the bit complement of the number. The bit complement (also called one's complement) is the result of exchanging 0s & 1s in the binary representation of a number. Stated differently, the one's complement of a binary number is formed by taking the positive number and inverting (complementing) all of the bits. Thus, the one's complement of the binary number 11011001 (217 in base 10) is 00100110. A problem with one's complement notation is that there are 2 representations of the value zero (a positive and a negative representation). Having two representations for the value zero is akward algebraically, so an alternative way of representing negative binary numbers has been developed.

The alternative to one's complement notation is called two's complement notation. Two's complement notation has a single representation of the value zero. Formally, two's complement notation can be defined as: "A binary representation for integers in which a negative number is one greater than the bit complement of the positive number". The two's complement representation is obtained by adding one to the one's complement representation. To obtain two's complement representation, 2 steps are performed:

(1) Obtain one's complement representation by reversing all bits; i.e., wherever there is a 0, make it a 1, and wherever there is a 1, make it a 0.

(2) Add 1 to your answer obtained from step 1.

Example

(00101010)2 = (42)10

Step 1: Reverse all bits    11010101
Step 2: Add 1                 + 00000001
   
                                         11010110 (Two's complement representation)

To add in binary do the following: zero plus zero is zero; one plus zero is one; and one plus one is zero with a one carried to the next place to be added to the next significant bit.

We can let the most significant (left most) bit represent the sign bit. Then if the sign bit is one, the number is negative; if the sign bit is zero, the number is positive.

 

Magnitude of signed binary numbers

Integer data is stored in memory in a binary format which can be treated as either signed or unsigned quantities. As unsigned quantities, integers extend upward from 0. As an example, an 8 bit address (byte) can contain any value from 0 to 255. Considering signed numbers, if we want to accomodate an equal amount of positive and negative numbers, an 8 bit address can contain numbers from -128 to +127 or -2 to 2 - 1.

The reason why they are not both 2 is because one combination is taken up for the zero value. The range is -128 to +127 (and not -256 to +255) because one bit is used to indicate the sign of the number and, thus, is not used for containing a value.