0% found this document useful (0 votes)
23 views52 pages

Binary Numbers

Uploaded by

ginol76330
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views52 pages

Binary Numbers

Uploaded by

ginol76330
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Module Name: Computer

and Network Systems


Module Code: UFCF93-30-1

Prashant Dhewaju
Module schedule
Week Theory Practical MOs Course Campus/Online
Works
Release
W1 Course overview, Computer Hardware: Introduction to Introduction of Computer Hardware + Digital 1,2 Online
Number system, Digital Systems, Logic logic Circuit Experiments
W2 Computer Hardware: Encoders / Decoders, Memory Decoders/Encoders circuits + Memory Circuits 1,2 CW1 Online
Segments, Shift + Shift Circuits
W3 Addition, Subtraction, Multiplication, Division. Putting Adder + Subtractor + Multiplier + Divider 1,2 CW2 Campus
all the Logic together Circuits
W4 Computer Hardware: I/O interrupts, Assembly language Assembly programming: Data structure, 2,3, 5 Campus
and memory segments, Mod functions, output at Addressing
specific location
W5 Indirect Memory addressing, Indirect addressing, Flag Assembly programming: Examples using 3,6
register, Semi-conditional loops, Programming, different interrupts Campus
languages
W6 Programming languages and compilers, different Programming in C + Data Structures in C 4,6,7
techniques to Program, Data structures, Stack and
Queues Campus
W7 Link lists, Linear Arrays, Representation of arrays in Link list + Arrays + Memory + Trees in C 7,8 CC1
memory, Trees Online
W8 Introduction to Networks, client server model, types of Network Cabling & Testing 6, 8 Online
networks, transmission media
Cont…
W9 Characteristics of transmission media, Basics of Linux commands 5,8 CW3 Campus
cellular networks, network topologies

W10 Cryptography and network security, AES and RSA Encryptions + SHA2 5,8 Campus
Security attacks and encryption Hash Function in C
W11 Operating System, memory Linux file management and shell 5,8 Campus
management, processor management, scripting
device management,
W12 File management, Security, Processes Finite State machines 4,6 Campus
and threads, Finite State machines Programming in C

W13 Introduction to Linux and Unix, Building a heterogeneous 5,8 Online


Comparison between Linux and topology (Linux & Microsoft OS)
Microsoft Windows
W14 Revision Revision 8,9 Online
W15 FINAL EXAM [COMP A] CC2
Assessments
• Component-A (50%)
1. An online exam of 50% total modules marks (MCQ based Exam) - Week 7
2. An online exam of 50% total modules marks (MCQ based Exam) - Week 14

• Component-B (50%)
1. Library Assignment 5% total module marks, will be announced in 2nd week.
2. Programming assignment 1 with report (800 words) 22.5% module marks
3. Programming assignment 2 with report (800 words) 22.5% module marks
Introduction and context
Computer Hardware
1.The Principal Functional Units and the Fetch-execute cycle
2. Interrupts
3. Numbers and Logic circuits
4. Memory circuits
5. Adding, Subtraction, Multiplication, Division circuits.
Operating Systems
1. Memory Management and Scheduling
2. Processes and Threads
3. Introduction to Linux
4. Comparing Windows and Linux

Caching Programming
1. Languages and Compilers
2. Different ways to programme
3. Finite State Machine
4. Using Threads and Semaphores
5. Data Structures
Introduction and context
Networking
1. LAN and WAN
2. Cell Phone Network
3. Client Server
4. Security Problems
5. Security Solutions
Rounding up
1. The move to low power consumption and sustainability
2. Pulling it all together
Lecture Content
• Bases
• Floating Point
• Storing Numbers
• Strings
Numbers
• an arithmetical value, expressed by a word, symbol, or
figure, representing a particular quantity and used in
counting and making calculations.
We use denary (Base 10)

Most likely as we have ten fingers

The number 7 can be written as 7 10

Where this indicates the base of the number


The number 1234 is made up of...

1 * 1000 + 2 * 100 + 3 * 10 + 4 * 1
Which is the same as...
3 2 1 0
1 *10 + 2 * 10 + 3 * 10 + 4 * 10
This pattern is true for any base...
1234 = 1 * 103 + 2 * 102 + 3 * 101 + 4 * 100

1234 = 1 * 53 + 2 * 52 + 3 * 51 + 4 * 50

1234 = 1 * 73 + 2 * 72 + 3 * 71 + 4 * 70

1234 = 1 * 83 + 2 * 82 + 3 * 81 + 4 * 80

1234 = 1 * 163 + 2 * 162 + 3 * 161 + 4 * 160


Importance of Number System and Bases

Mars climate orbiter failure report


In computing however, we are only interested in Bases 2, 10 and
16

We use to use Base 8 (Octal) but it is rarely used any more


• Base 2 is known as binary
• Base 10 is known as denary
• Base 16 is known as hexadecimal (or hex for short)
Conversions of Bases
Converting between Base 10 and Bases 2 and 16 is
difficult
Converting between Base 2 and Base 16 is easy
If fact we use Base 16 as a more convenient way to write
Base 2 numbers
Converting from Base 10 to Base 2 or 16 is the hardest...

First, what is the So our binary


Let's convert 23 largest power of 2 It is 2 to the power number is 1???? and
(base 10) into binary that is smaller than of 4 i.e. 16 we 23 -16 (i.e. 7) left
23? to convert to binary

Next is 2 to the
No, so we now have What about 2 to the Yes, so we have
power of 3 (i.e. 8)
10??? power of 2 (i.e. 4)? 101??, leaving 3
less than 7?

Finally we have
Next we have 10111 which is
1011?, leaving 1 binary for 23
Hexadecimal numbers have the range 0 to 15...

We do not have enough numbers to represent 16 digits so we use letters as well

The hexadecimal numbers are...


0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F
Where...
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
Representing denary into binary
Decimal Number 4-bit Binary Number Hexadecimal Number

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
Converting between hex and binary is easy...
Let's convert A79 to binary
• A is 1010, 7 is 0111 and 9 is1001

• So A79 in hex is 1010 0111 1001 in binary


Computer and Network Systems CC1 January
2016
What is the hexadecimal number 30 when it is represented as a
decimal number?
Answer = 48
Computer and Network Systems CC1 January
2016
What is the decimal number 32 when it is represented as a
hexadecimal number?
Answer = 20
Computer and Network Systems CC1 January
2016
What is the hexadecimal number 47 when it is represented as a
decimal number?
Answer = 71
Interpreting
Floating Point
Numbers
Floating Point Number
• A type of numeric data used in computing and mathematics. It is used to represent
numbers with fractional parts, such as 3.14159 or 0.1 and whole numbers
• Integer represent only whole numbers.
• They consist of a sign, mantissa, and exponent, which represent the magnitude and
precision of the number.
• Floating-point numbers are used extensively in scientific and engineering applications,
as well as in computer graphics and financial calculations.
Example 1
What is the floating-point value of the 32-bit hexadecimal
number C2B14000?
Q. C2B14000
Step 1→Throw away the trailing zeros giving C2B14
Step 2 → Convert to binary giving 1100 0010 1011 0001 0100
Step 3 → Split the binary like so...
1 - 10000101 – 01100010100
the first bit is the sign bit the next eight are the exponent and what is left is
the fractional part of the mantissa
Step 4 → Convert the exponent to denary (base 10) giving 133
Step 5 → Subtract 127 from the exponent, which is currently 133, giving 6
Step 6 → Take the fractional part of the mantissa (01100010100) and place 1. on
the front giving 1. 01100010100
Step 7 → The exponent is +6 so we need to move the decimal place in the mantissa 6
places to the right

1.01100010100
giving 1011000.10100
Step 8 → Convert 1011000.10100 to denary, do the bit to the left first...
1011000 = 64 + 16 + 8 = 88
Step 9 → Convert the bit on the right...
.10100 = 1/2 + 1/8 = 0.5 + 0.125 = 0.625
Step 10 → Add the two halves together giving 88.625
Step 11 → Remember the sign bit is 1? This means that it is a negative number so the
answer is -88.625
Example 2
What is the floating-point value of the 32-bit hexadecimal
number 43086000?
Q. 43086000
Step 1 → Throw away the trailing zeros giving 43086
Step 2 → Convert to binary giving 0100 0011 0000 1000 0110
Step 3 → Split the binary like so...
0 – 10000110 - 00010000110
the first bit is the sign bit the next eight are the exponent and what is left is the fractional part of the
mantissa
Step 4 → Convert the exponent to denary (base 10) giving 134
Step 5 → Subtract 127 from the exponent, which is currently 134, giving 7
Step 6 → Take the fractional part of the mantissa (00010000110) and place 1. on the front giving
1.00010000110
Step 7 → The exponent is +7 so we need to move the decimal place in the mantissa 7 places to the right

1.00010000110
giving 10001000.0110

Step 8) Convert 10001000.0110 to denary, do the bit to the left first...


10001000 = 128 + 8 = 136
Step 9) Convert the bit on the right...
.0110 = 1/4 + 1/8 = 0.25 + 0.125 = 0.375
Step 10) Add the two halves together giving 136.375
Step 11) Remember the sign bit is 0? This means that it is a positive number so the answer is 136.375
Computer and Network Systems CC1 January 2015
What is the 32-bit hexadecimal value represented by the floating point
number 60.125?

Answer = 42708000
Computer and Network Systems CC1 January
2015
What is the 32-bit hexadecimal value represented by the floating point
number 33.750?

Answer = 42070000
Computer and Network Systems CC1 January
2016
What is the 32-bit hexadecimal value represented by the floating point
number -86.500?

Answer = C2AD0000
Computer and Network Systems CC1 January
2016
What is the floating-point value represented by the 32-bit hexadecimal
number 42418000?

Answer = 48.375
Storing Integer
Numbers
Storing Numbers in computer

Well in C we can define char, short, long and int


• char is an 8-bit number
• short is an 16-bit number
• long is an 32-bit number
• int can be either 16 or 32 bit (on the PC it is 32 bit)
• In the program...
• int i;
• i = 28;
• The value stored in location i is...
• 00000000000000000000000000011100
Integers can be signed or unsigned
An 8-bit integer has values from
• -128 to +127 if signed
• 0 to 255 if unsigned

A 16-bit integer has values from


• -32768 to 32767 if signed
• 0 to 65535 if unsigned
But the important
thing is that they
have a range…
…the numbers that we experience in real-life don’t
have a range!
What does this means
• Real World
-∞ to ∞

• Signed 8-bit world


-128 to 127

• Signed 32-bit world


-2,147,483,648 to 2,147,483,647
Case Study 2

The first flight of the crewless Ariane 5 rocket


Endianness
• Endianness is a term that describes the order in which a sequence
of bytes is stored in computer memory.
• Endianness can be either big or small, with the adjectives referring to
which value is stored first.
• Big-endian is an order in which the “big end” (Most significant bit) is
stored first at lowest address.
• Little-endian is an order in which the "little end" (least significant
value in the sequence) is stored first at lowest address
Endianness
Example – let’s consider the two bytes of hexadecimal number 4F52.

Big-endian little-endian
Address contents Address contents
0x1000 4F 0x1000 52
0x1001 52 0x1001 4F

This is also true for transmitting data….


Chars
• C uses char type to store characters and letters. However, the char
type is integer type because underneath C stores integer numbers
instead of characters.
• In C, char values are stored in 1 byte in memory,and value range from
-128 to 127 or 0 to 255.
Array
• Arrays are used to store multiple values in a single variable, instead of declaring separate
variables for each value.
• To create an array, define the data type (like int) and specify the name of the array
followed by square brackets [].
• Two types of Array
• Single dimension arrays – e.g. myNumbers[0]
• Multidimensional arrays – e.g. matrix[2][3]
Computer and Network Systems CC1 January 2016
Which is the correct way to define a 4 by 5 character array called
names in the C programming language?

A. char names [4, 5];


B. names char[4][5];
C. names: char [4,5];
D. char names [4][5];
How do we store
strings?
Firstly, characters can be
stored as 8-bit unsigned
integers (ASCII)

Though 16-bit unsigned


integers are used to give us
many more symbols
Method of storing strings
Length of string

Characters
Null terminator

Characters
Case Study 3
spoofing ssl certificates strings
Thank you

You might also like