Number Systems

Decimal Number System (base 10)

Binary Number System (base 2)

Hexadecimal Number System (base 16)

 

Decimal

Binary

Hexadecimal

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

 

Converting Binary => Hexadecimal

Converting Hexadecimal => Binary

Converting Binary/Hexadecimal => Decimal

Converting Decimal => Binary/Hexadecimal

Arithmetic

Binary Addition

                           1        11
  0       0       1         1        1
+ 0     + 1     + 0      +  1     +  1
  0       1       1        10       11


 111111
  11010110
+  1101101
 101000011

Binary Subtraction

                             02
   0        1        1       10
-  0     -  0     -  1     -  1
   0        1        0        1



    1
   02202  02
  1100101110
-   11010001
  1001011101

Hexadecimal Addition

  A27CB4            39CDF106
+ 6E3095           + A6F278C
 110AD49            443D1892

Hexadecimal Subtraction

  A52CF3            3B0029
- 2B7169          - 1765A4
  79BB8A            239A85

Storage

The main storage of a computer’s memory is made up of bits (aka binary digits).

1 bit => binary 0 or 1

1 byte => 8 bits => 2 hex digits

1 halfword => 2 bytes => 16 bits => 4 hex digits

1 fullword => 4 bytes => 32 bits => 8 hex digits => 2 halfwords

1 doubleword => 8 bytes => 64 bits => 16 hex digits => 2 full words

Largest positive hexadecimal value that can be stored: 7FFFFFFF

Largest positive binary value: 01111111111111111111111111111111

Negative numbers are stored by taking the two’s complement of the absolute value of the number.

To find binary 2’s complement:

  1. Switch all of the 0s to 1s and 1s to 0s (finding the 1’s complement)
  2. Add 1
100111100 => 011000011
           +         1
             011000100

To find hexadecimal 2’s complement:

  1. Subtract the number from FFFFFFFF
  2. Add 1
  FFFFFFFF          FFFFFFFF          FFFFFFFF
- 002BCF06        - 00000001        - FFD430FA
  FFD430F9          FFFFFFFE          002BCF05
+        1        +        1        +        1
  FFD430FA          FFFFFFFF          002BCF06

Arithmetic using the two’s complement:

Overflow:

Occurs when a number becomes too large for its representation scheme.

To check for overflow:

  1. Convert the 1st digit of each number to binary
  2. Add the binary values together
  3. If the last two carry bits are the same, no overflow.
  4. If they are different, overflow.
                   00  <=  NO overflow
  729B6320     7 => 0111
+ 8A5C973C     8 => 1000
  FCF7FA5C          1111


                   10  <=  overflow
  92B176C0     9 => 1001
+ 859237A4     8 => 1000
  1843AE64          0001


                                              01111  <=  overflow
  328AC105                  328AC105    3 =>   0011
- 807B96AF => 7F846951 => + 7F846951    7 => + 0111
                            B20F2A56           1011