Uploaded by victor.encinares

How Computer Works

advertisement
How Computer Works
Gec Elect 21.4 – Living in the IT Era
Chapter 3
The Number System
Lesson 1
Introduction
When we type words onto a computer, it will translate them
into numbers. In fact, to a computer, all information is
written as series of 1s and 0s. Computer number
systems are how we represent numbers in a computer
system architecture.
Humans have been counting for a long time. To do so, we
use systems that relate unique symbols to specific values.
This is called a number system, and it is the technique that
we use to represent and manipulate numbers
Computers support the
following number systems:
Binary
Octal
Decimal
Hexadecimal
How it works
You are probably most familiar with the decimal system that forms the
basis of how humans count. The decimal system has a base of 10,
because it provides 10 symbols to represent all numbers:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Humans use the decimal system because we have 10 fingers to count
on, but machines don’t have that luxury. So, we’ve created other
number systems that perform the same functions. Computers represent
information differently than humans, so we need different systems to
represent numbers.
BINARY
DECIMAL
OCTAL
HEXADECIMAL
BASE 2
BASE 10
BASE 8
BASE 16
01
0123456789
01234567
0123456789
ABCDEF
a2
a10
a8
a16
“binarius” (Latin)
=> two
“decem” (Latin) =>
ten
“octo” (Latin) =>
eight
“hexa” (Greek) =>
six
“decem” (Latin) =>
ten
A “BIT” IS A BINARY DIGIT
A “BYTE” is made up of 8 bits in a sequence.
Introduction to the Binary
Number System
A computer uses bits to represent information. A bit is the most basic
unit of storage in a computer. An essential component of computers is
called the transistor. Just like a light switch, the transistor either allows
or prevents current to flow. So, it only has two states: on and off.
Every number in a computer is an electrical signal. In the early days of
computers, electrical signals were representing with an “on” state (a
negative charge) and an “off” state (a positive charge). This forms a kind
of binary switch.
These two states can be represented using one of two symbols: 1 and 0.
This means that the binary number system has a base of 2. Only
symbols are needed to represent every number.
Instead of representing numbers as individual units (like the number 10 or 400), we
use groups of 1s and 0s. For example, here is what it looks like when a computer
counts from 0 to 10:
This is called the binary number system. Each binary digit is referred to as a bit. For
instance, 01100110 is composed of 4-bits which are 00, 11, 11, and 00. When it
comes to placing values to the bits (i.e. digits) in this system, we place values
corresponding to ascending powers of 2 from right to left.
Hexadecimal Numbers
In addition to binary, another number base that is commonly used in digital
systems is base 16. This number system is called hexadecimal, and each
digit position represents a power of 16. For any number base greater than
ten, a problem occurs because there are more than ten symbols needed to
represent the numerals for that number base.
It is customary in these cases to use the ten decimal numerals followed by
the letters of the alphabet beginning with A to provide the needed
numerals. Since the hexadecimal system is base 16, there are sixteen
numerals required. The following are the hexadecimal numerals:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
The following are some examples of hexadecimal numbers:
1016 4716 3FA16 A03F16
Octal Number System
Octal Number System is one in which the base value is 8. It uses 8 digits
i.e. 0-7 for the creation of Octal Numbers. Octal Numbers can be
converted to Decimal values by multiplying each digit with the place
value and then adding the result. Here the place values are 80, 81, and
82. Octal Numbers are useful for the representation of UTF8 Numbers.
Example,
13510 can be written as 2078
21510 can be written as 3278
Conversion Scheme
BINARY TO
DECIMAL
BINARY TO
OCTAL
BINARY TO
HEXADECIMAL
DECIMAL TO
BINARY
DECIMAL TO
OCTAL
DECIMAL TO
HEXADECIMAL
HEXADECIMAL
TO BINARY
HEXADECIMAL
TO DECIMAL
HEXADECIMAL
TO OCTAL
OCTAL TO
BINARY
OCTAL TO
DECIMAL
OCTAL TO
HEXADECIMAL
NUMBER SYSTEM CONVERSION
DIAGRAM
BINARY
HEXADECIMAL
DECIMAL
OCTAL
1. BINARY TO DECIMAL
10112
Method:
(1011)₂ = (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰)
=(1 x 8) + (0 x 4) + (1 x 2) + (1 x 1)
=8+0+2+1
=
1110
2. BINARY TO OCTAL
Example 1: Convert 10101012 to octal
Solution:
Given binary number is 10101012
First, we convert given binary to decimal
10101012 = (1 * 26) + (0 * 25 ) + (1 * 24) + (0 * 23) + (1 * 22) + (0 * 21) + (1 * 20)
= 64 + 0 + 16 + 0 + 4 + 0 + 1
= 64 + 21
0101012= 85 (Decimal form)
Now we will convert this decimal to octal form
Therefore, the equivalent octal number is
1258.
3. BINARY TO HEXADECIMAL
Making Basic Conversions
Convert 1010 to Hexa
Converting Long Binary Strings
4. DECIMAL TO BINARY
Performing Short Division by Two with Remainder
Descending Powers of Two and Subtraction
5. DECIMAL TO OCTAL
Example 1: Convert (127)10 to Octal.
Solution: Divide 127 by 8
127 ÷ 8= 15(Quotient) and (7)Remainder
Divide 15 by 8 again.
15 ÷ 8 = 1(Quotient) and (7) Remainder
Divide 1 by 8, we get;
127 / 8
15 / 8
7
1 / 8
7
0 / 8
1
1 ÷ 8 = 0(Quotient) and (1) Remainder
Since the quotient is zero now, no more division can be done. So by taking
the remainders in reverse order, we get the equivalent octal number.
Hence, (127)10 = (177)8
DECIMAL TO HEXADECIMAL
Download