M. Amer Iqbal Qureshi



tải về 3.06 Mb.
Chế độ xem pdf
trang12/132
Chuyển đổi dữ liệu09.12.2022
Kích3.06 Mb.
#53945
1   ...   8   9   10   11   12   13   14   15   ...   132
Amer Iqbal - Teach Yourself PIC Microcontrollers for Absolute Beginners-Microtronics Pakistan (2001)

Number system conversion 
Binary number system is the most commonly used and decimal system is the most understandable while 
hexadecimal system is somewhere between them. Therefore, it is very important to learn how to convert 
numbers from one number system to another, i.e. how to turn series of zeros and units into values 
understandable for us. 
Binary to decimal number conversion 
Digits in a binary number have different values depending on their position in that number. Additionally, 
each position can contain either 1 or 0 and its value may be easily determined by its position from the right. 
To make the conversion of a binary number to decimal it is necessary to multiply values with the 
corresponding digits (0 or1) and add all the results. The magic of binary to decimal number conversion 
works...You doubt? Look at the example: 
110 = 1*2^2 + 1*2^1 + 0*2^0 = 6 
It should be further noticed that for decimal numbers from 0 to 3 it is enough to have two binary digits. For 
greater values, new binary digits must be added. Thus, for numbers from 0 to 7 it is enough to have three 
digits, for numbers from 0 to 15- four digits etc. Simply speaking, the largest binary number consisting of n 
digits is obtained when the base 2 is raised by n. The result should be afterwards subtracted by 1. For 
example, if n=4: 
2^4 - 1 = 16 - 1 = 15 
Accordingly, using 4 binary digits it is possible to represent decimal numbers from 0 to 15, including these 
two digits, which amounts to 16 different values in total. 
Hexadecimal to decimal number conversion 
In order to make conversion of a hexadecimal number to decimal, each 
hexadecimal digit should be multiplied with the number 16 raised by it’s position 
value. For example: 
Hexadecimal to binary number conversion 
It is not necessary to perform any calculation in order to convert hexadecimal 
number to binary number system. Hexadecimal digits are simply replaced by the 
appropriate four binary digits. Since the maximal hexadecimal digit is equivalent to decimal number 15, it 
is needed to use four binary digits to represent one hexadecimal digit. For example: 

tải về 3.06 Mb.

Chia sẻ với bạn bè của bạn:
1   ...   8   9   10   11   12   13   14   15   ...   132




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©hocday.com 2024
được sử dụng cho việc quản lý

    Quê hương