Sunday, October 21, 2012

Number System

Number System

A number system is a basic symbol to represent a set of quantities. There are a lot of number system. Here we only focus on the decimal, hexadecimal and binary number.

Most if the numbering system will have a base. The maximum number that can be represented on the single digit or number is called base.

Decimal number
  • Base of 10
  •  The value of the assigned weight is composed by 10 digits starting from 0-9
Binary number
  • Base of 2
  • The number consists of only two digits which is 0 and 1
Hexadecimal number
  • Base of 16
  • The composed number is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F.
                                              
 Number System Cenversion

 Second Complement Number

In microprocessor-based equipment, second complement method of representing number is commonly used. Until now, we only assume that the numbers are positive. However, microprocessor must proceed both positive and negative number.

Assume a microprocessor have 8 register bits. The most significant bit (MSB bit which is first bit from left) is 0, then the number is positive (+). Conversely, the MSB bit is 1, then the number is negative (-). The other remaining 7 bits are represent as the magnitude numbers. The first bit from right is a least significant bit (LSB).

Example:

Q1: convert decimal number -125 to binary 


Decimal
8-bits binary number
Notes

Sign
Magnitude

125
0
111 1101
Convert 125 to 7-bits binary

0
000 0010
1st complement (each 0 is changed to 1, each 1 to 0)

0
000 0011
2nd complement (Add +1 to the 1st complement)
-125
1
000 0011
Magnitude number

No comments:

Post a Comment