Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Class 1 (Lecture notes)

The document provides an overview of binary and hexadecimal systems, explaining their base values and conversion methods between binary, denary, and hexadecimal formats. It includes examples of converting numbers and practical applications in computer systems, particularly in controlling devices like robot vacuum cleaners. Additionally, it outlines memory size measurements in bits, bytes, and larger units, along with their denary equivalents.

Uploaded by

Sameer Javed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Class 1 (Lecture notes)

The document provides an overview of binary and hexadecimal systems, explaining their base values and conversion methods between binary, denary, and hexadecimal formats. It includes examples of converting numbers and practical applications in computer systems, particularly in controlling devices like robot vacuum cleaners. Additionally, it outlines memory size measurements in bits, bytes, and larger units, along with their denary equivalents.

Uploaded by

Sameer Javed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Chapter one

Binary systems
and hexadecimal

OL Computer science 2 Nepal Ammer


The binary system
Binary system is a base 2 system, It uses 0 and 1 only, All computers consists of tiny switches which
use the binary system as switches must be in the ON (1) or OFF (0) position.
It has units/ placeholders/column headings that increase by the power of 2

128 64 32 16 8 4 2 1
27 26 25 24 23 22 21 20

In Denary system is a base 10 system, it uses 0 to 9 values, it counts in multiples of 10 which give us
the well-known headings of units, 10s, 100s, 1000s and so on, It has units/ placeholders/column
headings that increase by the power of 10.

10,000 1,000 100 10 1


104 103 102 101 100

Convert from Binary to Denary

Each time a 1 appears in a column, the column value is added to the total and the 0 values are ignored.

Example: convert 1 1 1 0 1 1 1 0 to a denary value

= 128 + 64 + 32 + 8 + 4 + 2 =238 (Denary)

27= 128 26= 64 25= 32 24= 16 23= 8 22= 4 21= 2 20= 1


1 1 1 0 1 1 1 0

Convert from Denary to Binary

Method (1) using trial and error:

This method involves placing 1s in the appropriate position so that the total equates to the denary
value.

Example: convert 107 to a binary value

27= 128 26= 64 25= 32 24= 16 23= 8 22= 4 21= 2 20= 1


0 1 1 0 1 0 1 1
64 + 32 = 96 96+16=112 96 + 8= 104 104+4 =108 104 + 2 =106 106 + 1 =107

The binary number is = 0 1 1 0 1 0 1 1

(Note: the maximum denary value of a binary value that consists of n digits, is = (2^n)-1
Example: 1111 1111 (8 digits) àmax value is (27+26+25+24+23+22+21+20= 255=28-1=256-1)

OL Computer science 3 Nepal Ammer


Method (2) using division:

This method involves successive division by 2. The remainders arc then read from BOTTOM to TOP
to give the binary value.

Example: convert 107 to a binary value

107/2
=53/2 Remainder =1
=26/2 Remainder =1
=13/2 Remainder =0
=6/2 Remainder =1
=3/2 Remainder =0 Read the remainder from bottom to top to
=1/2 Remainder =1 get the binary value: 0 1 1 0 1 0 1 1
=0/2 Remainder =1
0 Remainder =0
Example use of binary

1) In computer registers (Robots)


A robot vacuum cleaner has three wheels, A, B and C. A rotates on a spindle to allow for direction
changes (as well as forward and backward movement); B and C are fixed to revolve around their
spindle to provide only forward and backward movement, and have an electric motor attached :

An 8-bit register is used to control the movement of the robot vacuum cleaner:

Motor B Motor B Motor C Motor C B direction B direction C direction C direction


ON OFF ON OFF Forward Backward Forward Backward
If the register/input contains 1 0 1 0 1 0 1 0 this means motor B is ON and motor C is ON and both
motors are turning to produce FORWARD motion. So, the vacuum cleaner is moving forwards.

1 0 1 0 1 0 1 0
Motor B Motor B Motor C Motor C B direction B direction C direction C direction
ON OFF ON OFF Forward Backward Forward Backward

1 1 1 1
Motor B Motor C B direction C direction
ON ON Forward Forward

OL Computer science 4 Nepal Ammer


Questions

i) What would be the effect if the register contained the following values 1 0 0 1 1 0 0 0

1 0 0 1 1 0 0 0
Motor B Motor B Motor C Motor C B direction B direction C direction C direction
ON OFF ON OFF Forward Backward Forward Backward
Moto B is On and moving in the forward direction, while motor C is off and doesn’t move at all.

ii) What would the register contain if only motor C was ON and the motors were turning in a
BACKWARDS direction?

Motor B Motor B Motor C Motor C B direction B direction C direction C direction


ON OFF ON OFF Forward Backward Forward Backward
0 0 1 0 0 0 0 1

iii) What would the register contain if motor B and motor C were both ON but B was turning in a
backward direction and C was turning in a forward direction?

Motor B Motor B Motor C Motor C B direction B direction C direction C direction


ON OFF ON OFF Forward Backward Forward Backward
1 0 1 0 0 1 1 0

iv) What would be the effect if the register contained the following 11111111?

An error occurs and the vacuum cleaner will stop.

2) Measurement of the memory size of computer systems


A binary digit is commonly referred to as a bit; 8 bits are usually referred to as a byte is the
smallest unit of memory in a computer.
Measuring units
Name of the
Equivalent Denary value
memory size
1 bit
1 nibble 4 bits 0.5 byte
1 byte 8 bits
1 KB (kilo byte) 210bytes 1,024 bytes
20
1 MB (Mega byte) 2 bytes =1024*1024 = 1,048,576 bytes
30
1 GB (Gega byte) 2 bytes =1024*1024*1024 = 1,073,741,824 bytes
40
1 TB (Tera byte) 2 bytes =1024*1024*1024 *1024 = 1,099,511,627,776 bytes
50
1 PB (Peta byte) 2 bytes =1024*1024*1024 *1024 *1024 = 1,125,899,906,842,620 bytes

Examples giving the use of these numbers,


Internet: if the data transfer rate using is 32Megabits/ second (32 Megabits = 4 Megabytes/1
sec), so 40 Mb image will take 10 second to be transferred

2 terabyte Hard disc = 2* (1024*1024 MB) = 2* (1,048,576 MB) =2,097,15 MB, means they can
store about half a million 4 MB photos (524,288 * 4MB)
OL Computer science 5 Nepal Ammer
The hexadecimal system
In Hexadecimal system (base 16 à uses from 0 to 9 and letters from A to F = 16 values), it counts in
multiples of 16 (164 =65,536 163 = 4,096 162=256 161=16 160=1)

Binary
Denary Hexadecimal 3 2
2 =8 2 =4 21= 2 20= 1
0 0 0 0 0 0
1 1 0 0 0 1
2 2 0 0 1 0
3 3 0 0 1 1
4 4 0 1 0 0
5 5 0 1 0 1
6 6 0 1 1 0
7 7 0 1 1 1
8 8 1 0 0 0
9 9 1 0 0 1
10 A 1 0 1 0
11 B 1 0 1 1
12 C 1 1 0 0
13 D 1 1 0 1
14 E 1 1 1 0
15 F 1 1 1 1

Converting from binary to hexadecimal and from hexadecimal to binary

Converting from binary to hexadecimal is done by starting from the right and moving left, split the
binary number into groups of 4 bits. If the last group has less than 4 bits, then simply fill in with 0s
from the left.

Example: 00110011110101110 à 067AE

0 0110 0111 1010 1110


0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 1 0
23 22 21 20 23 2 2 2 2 2 2 2 2 2 2 2 2 22 21 20
2 1 0 3 2 1 0 3 2 1 0 3

8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
0 4+2=6 4+2+1= 7 8+2=10=A 8+4+2=14=E
Converting from hexadecimal to binary is done by taking each hexadecimal digit and write down the
4-bit code which corresponds to the digit

Example: BF08 à 1011 1111 0000 1000

B= 11 F=15 0 8
3
2 2 2 2 2 2 2 2 2 2 2 2 2 2 21 20
2 1 0 3 2 1 0 3 2 1 0 3 2

8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
1 0 1 1 1 1 1 1 0 0 0 0 1 0 0 0

OL Computer science 6 Nepal Ammer


Converting from hexadecimal to denary and from denary to hexadecimal

To convert a hexadecimal number to denary, take each hexadecimal digit and multiply it by its value .
Add the totals together to obtain the denary value.

Example: 45A à 1114


4 5 A=10
2 1
16 =256 16 =16 160=1
4*256=1024 5*16=80 10*1=10
1024 + 80 + 10 = 1114

To convert from denary to hexadecimal we’ll use the same methods used to convert from Denary to
Binary:

Method (1) using trial and error:

This method involves placing a value in the appropriate position so that the total equates to the
denary value.

Example: convert 2004 to a hexadecimal value

163= 4,096 162= 256 161= 16 160= 1


7 *256=1792 13*16=208 4*1=4
1792 + 208 = 2000
The hexadecimal is 7 D 4 [7 13 4]

Method (2) using division:

This method involves successive division by 16. The remainders arc then read from BOTTOM to TOP
to give the hexadecimal value.

Example: convert 2004 to a hexadecimal value

2004/16
=125/16 Remainder =4 Read the remainder from bottom to top to
=7/16 Remainder =13=D get the hexadecimal value: 7 D 4
=0 Remainder =7

Note:

To convert from hexadecimal to denary; you can convert from Hexadecimal to binary and from binary
to denary, you can do the same for the conversion from denary to hexadecimal (denary à binary à
hexadecimal)

OL Computer science 7 Nepal Ammer

You might also like