0% found this document useful (0 votes)
5 views

TM112 Meeting2-Binary Data Representation

The document provides an introduction to binary data representation and computation, focusing on how computers represent and process data using binary, decimal, octal, and hexadecimal systems. It covers the significance of binary logic, the representation of integers and text in binary, and methods for converting between different number systems. Additionally, it discusses the implications of binary representation on data processing and potential errors that may arise from different representations.

Uploaded by

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

TM112 Meeting2-Binary Data Representation

The document provides an introduction to binary data representation and computation, focusing on how computers represent and process data using binary, decimal, octal, and hexadecimal systems. It covers the significance of binary logic, the representation of integers and text in binary, and methods for converting between different number systems. Additionally, it discusses the implications of binary representation on data processing and potential errors that may arise from different representations.

Uploaded by

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

TM112: Introduction to Computing

and Information Technology

Meeting #2
Block 1 (Part 2 )
Binary data representation and
computation
OU Materials, PPT prepared by Dr. Ahmad Mikati
April 16, 2025 TM112-AOU 1
Contents

• Introduction
• 2.1 Representing integers and text in binary
• 2.2 Decimal numbers and some limitations of binary
representations
• 2.3 Representing logic operations and logic circuits
• Summary

April 16, 2025 TM112-AOU 2


Introduction

• This part will provide you with a basic


understanding of how computers represent
and process data.
• After
studying it, you will be able to compare
some of the different binary representations of
data and reason about their efficiency.
• Also,you will appreciate that sometimes a
particular representation can lead to errors
(with potentially far-reaching consequences).

April 16, 2025 TM112-AOU 3


Binary logic
• Binary logic underpins most forms of digital technology. It was
developed in the mid-nineteenth century by George Boole.
• At the time, Boole was interested in exploring the fundamental
nature of truth, so he developed a system involving symbols – a
symbolic logic – to help him reason about truth and falsity. This
system is often referred to as Boolean logic or binary logic, and
it focuses on the manipulation of 1s and 0s (1 to represent TRUE
and 0 to represent FALSE).
• When trying to understand the nature of the digital world, it is
useful to know something about the binary numbers, because
binary numbers are the form in which information is held in a
computer.
• For example, 100011 can be considered as a binary number.
When stored in a computer, each digit of a binary number is
referred to as a bit, which is a contraction of the word’s binary
digit.April 16, 2025 TM112-AOU 4
1.1 Representing integers and
text in binary
• The printed symbols shown in Figure 2.1 provide
convenient representations of short and long
flashes of light or short and long bleeps of sound,
which is how Morse code is normally transmitted.

April 16, 2025 TM112-AOU 5


1.1 Representing integers and text in binary

• In any representation it is important that the


symbols can be distinguished from each other.
• Changes in electrical voltages or friction in
mechanical systems can cause random
fluctuations, called noise, which may distort how
the symbol is perceived.
• In a binary system there are only two symbols, so it
is generally easier to make them different enough
to be distinguishable – for example, Morse code
specifies that a dash should be three times as long
as a dot.

April 16, 2025 TM112-AOU 6


Binary representation systems in
computers

• Some very early computers, such as the ENIAC


(Electronic Numerical Integrator and Computer),
tried to represent data using our usual base-10
system. So, 0 volt was used to represent the digit
0, 1 volt to represent the digit 1, and so on, all the
way up to 9 volts to represent the digit 9.
• Hence, a lot of circuitry was needed just in order to
distinguish between the different voltages, which
took up a lot of space and generated a lot of heat.
• The advantage of representing data in binary is
that only two ranges of voltage need to be
detected.
April 16, 2025 TM112-AOU 7
Number systems
We have different number systems:
• Decimal (Base 10)
• It uses 10 symbols (0, 1, 2, 3, 4, 5, 6, 7, 8 and 9).

• Binary (Base 2)
• It uses 2 symbols (0 and1).

• Octal (Base 8)
• It uses 8 symbols (0, 1, 2, 3, 4, 5, 6 and 7).

• Hexadecimal (Base 16)


• It uses 16 symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F).

April 16, 2025 TM112-AOU 8


Number systems

• Decimal (Base 10) System


• The system that is used worldwide.
• It uses ten digits (0 to 9) and each column
counts groups ten times bigger than those
counted in the column to its right.

• Examples:
• 37 = 7 + 3*101
• 345 = 5 + 4*101 + 3*102
• 4621 = 1 + 2*101 + 6*102 + 4*103

April 16, 2025 TM112-AOU 9


Number systems

• Octal (Base 8) System


• The system that is mostly used by computer
scientist.
• It uses eight digits (0 to 7) and each column
counts groups eight times bigger than those
counted in the column to its right.

• Examples:
• 468 = 6 + 4*81 = 3810

• 1258 = 5 + 2*81 + 1*82 = 8510

April 16, 2025 TM112-AOU 10


Number systems

• Hexadecimal (Base 16) System


• The system that is mostly used by computer
scientist.
• It uses eight digits (0 to F) and each column
counts groups sixteen times bigger than those
counted in the column to its right. (A is
equivalent to 10 in decimal,….., F is equivalent
to 16 in decimal)

• Examples:
• 4616 = 6 + 4*161 = 7010

• A516 = 5 + 10*161 = 16510


April 16, 2025 TM112-AOU 11
Number systems

• Binary (Base 2) System


• The system that is used by the computer.
• It uses two digits (0 and 1) and each column
counts groups two times bigger than those
counted in the column to its right.

• Examples:
• 1102 = 0 + 1*21 + 1*22 = 610

• 11012 = 1 + 0*21 + 1*22 + 1*23 = 1310

April 16, 2025 TM112-AOU 12


Number systems
• A bit is short for binary digit and refers to a 1 or a 0
stored in the computer, while a byte is a group of eight
bits that can be used to represent numbers between 0
and 255.
• A byte looks like this:

• The largest number we can store in a byte is 11111111


= (255)10.

• The smallest number we can store in a byte is 00000000


= (0)10.


April 16, 2025 TM112-AOU 13
The word size for a computer is the number of bits that
the CPU of a particular computer can handle at one time.
Binary to Decimal Conversion
To convert from binary to decimal a method known as
Positional notation can be used. The below figures illustrate
the method with an example of how to convert 100110112 to
decimal.

April 16, 2025 TM112-AOU 14


Octal to Decimal Conversion
• To convert from octal to decimal the following formula can
be used:

Decimal Form = Ʃ(ai x 8i)


• Where, 'a' is the individual digit being converted, while 'i' is
the number of the digit counting from the right-most digit in
the number, starting with 0.
• Here are two examples:

April 16, 2025 TM112-AOU 15


Converting from Decimal to any Base
Given the integer part of a decimal number, you can find
the equivalent value in any base, n, as follows:
1. Divide the number by n.
2. You will get Quotient and Remainder. The remainder
will always be less than the base n. Keep this
remainder aside.
3. Use the quotient to repeat the above steps, until you
get a quotient equal to 0.
4. Now, group the remainders in order, such that the first
remainder will be the least significant bit, and the last
one will be the most significant bit.
Note that the highest-order bit is the leftmost bit, and it is called the most significant
bit (MSB).
On the other hand, the lowest-order bit is the rightmost bit, and it is called the least
significant bit (LSB).

April 16, 2025 TM112-AOU 16


Decimal to Binary Conversion

April 16, 2025 TM112-AOU 17


Decimal to Binary Conversion
• One of the easy methods used to convert from
decimal to binary is comparison with descending
powers of two and subtraction.
• To convert a number from binary to decimal notation,
we put the number in the table and add up the values
of each place value.
• So, to convert the binary number 1001 into decimal
notation, we can use the following table

Decimal number=
8+1=9

April 16, 2025 TM112-AOU 18


Decimal to Octal
The conversion of a decimal number to its octal
equivalent is done by the repeated division method. You
simply divide the base 10 number by 8 and extract the
remainders.
Here are two examples to illustrate this method:

April 16, 2025 TM112-AOU 19


Representing integers in binary
Unsigned integers

• In computer-speak, an unsigned integer is an integer


that is greater than or equal to zero.
• An unsigned integer is sufficient for any purpose where
a value does not become negative – for example, a
counter counting upwards from zero.
• The number of unsigned decimal values that we can
represent in binary depends on the number of bits we
have available. If there are 3 bits available, we can
represent 23 = 8 values. If we want to include 0, this
means that we can encode all of the unsigned integers
from 0 to 7 in three bits.

April 16, 2025 TM112-AOU 20


Representing integers in binary
Unsigned integers
• The largest decimal value that can be represented in
3 bits is 7. This is one less than 23 (or, in
mathematical notation, 23 – 1) because one of the 8
available codes has been used up to represent 0.
• This scheme can be extended to systems with more
bits.
• In general, if we have n bits, we can represent 2n
unsigned integers, and the largest integer that can
be represented is 2n – 1.

April 16, 2025 TM112-AOU 21


Adding unsigned integers in
binary notation
• In decimal notation, adding two positive integers is very
straightforward. The two values are added, and the sign
of the result is automatically positive.
• Similarly, if the values are represented as two unsigned
integers in binary notation, their binary values can just
be added.
• So, to add two binary numbers by hand, we use the
same method as adding two decimal numbers. The
numbers are written one under the other, so that each
column has the same place value. Then the digits in
each column are added, column by column from the
right, carrying digits as necessary.

April 16, 2025 TM112-AOU 22


Adding unsigned integers in
binary notation

• To illustrate, here is the working to add the two


unsigned integers 110 and 101, where the ‘carry’
digit is shown in blue below:

April 16, 2025 TM112-AOU 23


Sign-magnitude representation
Signed magnitude is the most intuitive method for
representing the unsigned numbers.
The MSB (Most Significant Bit) of a binary number is
kept as the “sign” of the number
MSB = 1: negative number
MSB = 0: positive number
The remaining bits represent the magnitude (or
absolute value) of the numeric value.

• So for our 3 bits, there would be 23 = 8 possible binary


codes, which could be used to encode positive and
negative integers as shown in Table 2.7.

April 16, 2025 TM112-AOU 24


Sign-magnitude representation
In an N bit word signed magnitude system
 1 bit is used for the sign of the number (MSB).
 N-1 bits are used for the magnitude of the
number.
 The largest integer is 2N-1- 1
 The smallest integer is -(2N-1- 1)
Example: In an 8 bit word signed magnitude system give the
decimal representation of the following numbers: 00000001,
10000001
Answer:
•00000001:
-The MSB is 0: The number is positive
-The remaining 7 bits are: 00000012 = 110
-The decimal number is +1
•10000001:
-The MSB is 1: The number is negative
-The remaining 7 bits are: 00000012 = 110
April 16, 2025 TM112-AOU 25
-The decimal number is -1
Representing text in binary
• Most modern systems for encoding text derive in part from
ASCII (American Standard Code for Information Interchange,
pronounced ‘askee’), which was developed in 1963.
• In the original ASCII system, upper-case and lower-case
letters, numbers, punctuation and other symbols and control
codes (such as a carriage return, backspace and tab) were
encoded in 7 bits. As computers based on multiples of 8 bits
(or a byte) became more common, the encoding system
became an 8-bit system, and so could be expanded to
include more symbols.
• When binary numbers were assigned to each character in
the original ASCII system, careful thought was given to
choosing sequences of values for the characters of the
alphabet and numerals that would make it easy for a
computer processor to perform common operations on them.
(These encodings were preserved in the 8-bit system by
simply padding out the leftmost bit with a 0.)
April 16, 2025 TM112-AOU 26
1.1.5 Representing text in binary

• Since 2007, the standard encoding system for


characters has been Unicode Transformation Format-
8 (UTF-8) which uses a variable number of bytes (up to
6) to encode characters in use across the world.
However, in order to maintain backward compatibility,
the original 127 ASCII codes are preserved in UTF-8.
April 16, 2025 TM112-AOU 27
Floating-point numbers and
scientific notation
• Consider the decimal number 2343.56. We could also
write this as 23.4356 × 102 OR 0.234356 × 104 or
234356.0 × 10–2.
• The decimal point can ‘float’ to any position as long as
the power of 10 is appropriate.
• Scientific notation is a special case of floating-point
notation where there is a single non-zero digit between
1 and 9 (inclusive) to the left of the decimal point.
• To express a number greater than 10 in scientific
notation, the first stage is to divide it repeatedly by 10
until it is reduced to a number that is less than 10.

April 16, 2025 TM112-AOU 28


Floating-point numbers and
scientific notation
• So, the number 2343.56 can be represented in
scientific notation as 2.34356 × 103. Note that the
exponent, 3, indicates that the decimal point should
be moved three places to the right to get back the
original decimal notation.
• Expressing a small number – between 0 and 1 – in
scientific notation involves a process very similar to that
for large numbers.
• Take –0.000654 as an example. First you move the decimal
point to the right until it sits after the first non-zero digit: -
00006.54
• Then multiply this number by 10 raised to the power of
minus the number of places the decimal point has been
moved:-6.54
April 16, 2025
× 10−4 TM112-AOU 29
Floating-point numbers and
scientific notation
• The number –0.000654 in decimal notation can be
written as -6.54 × 10–4 in scientific notation. Here, the
negative exponent (–4) indicates that the decimal point
should be moved 4 places to the left to get back to the
original decimal notation.
• Notice that scientific notation has three distinct parts,
shown in Figure 1.10:
• a sign
• an exponent (the power of 10)
• a mantissa (the decimal number part).

April 16, 2025 TM112-AOU 30


Representing logic operations and
logic circuits

• In the previous two sections, we have seen that we can


use binary encodings to represent numerical and textual
data. We will now see that operations, including
arithmetical operations such as addition, and comparison
operations such as less than and equals, can be encoded
as one or more logic operations. These logic operations
act on the binary representations of the data.
• To move from the human to the computer view, the
integers have to be encoded as binary representations
and the addition operator has to be encoded as a
sequence of logical operations that have what is called
the truth table.

April 16, 2025 TM112-AOU 31


Representing logic operations and
logic circuits
• A truth table for a logic operation lists all the possible
combinations of input values, and for each possibility
gives the output value for that operation. As the
operations we will consider will always be applied to
binary encodings, each input value must be either a 1
or a 0 and the result of the operation must also always
be a 1 or a 0.
• We will start by looking at the truth tables for three of
the fundamental logical operations defined by Boole.
We will then see how these basic operations can be
used as building blocks for the logic circuits that
perform more complex operations. By the end of this
subsection, you will see how these simple operations
can be used to build a logic circuit to add two binary
numbers.
April 16, 2025 TM112-AOU 32
Representing logic operations and
logic circuits
The NOT operation
• One of the most fundamental operations we might want
to perform is to ‘flip’ a single bit – let’s call the bit a. So, if
is 1, we want the result to be 0, and if is 0, we want the
result to be 1. This operation is called NOT and is
expressed as: or ’.
The behavior of NOT operator is characterized by the
truth table shown below:
To physically perform logic operations on binary
data in a computer, we need to use electrical
components. The components that represent the
most fundamental operations are called logic
gates, which can be combined in a logic circuit
in order to create more complex operations.
The NOT logic gate
The NOT truth table

April 16, 2025 TM112-AOU 33


1.3 Representing logic operations
and logic circuits
• The AND operation
• Most logical operations involve two input values. A truth
table for two binary inputs, x and y, has more rows
because there are four possible permutations (or ways
of combining) the two input values, as shown in
Table 2.19.
AND logic gate

AND truth table

April 16, 2025 TM112-AOU 34


Representing logic operations and
logic circuits
• The OR operation
• truth table for the logic operation OR (which Boole
originally designated by the symbol +) is shown below

OR logic gate

OR truth table

April 16, 2025 TM112-AOU 35


Building logic circuits
• Suppose we want to build a logic circuit with two inputs,
A and B, that tests if B is greater than A.
• The first step is to create a truth table showing the
desired outcomes: if B is greater than A, the result is 1
(True), otherwise the result is 0 (False).

April 16, 2025 TM112-AOU 36


Building logic circuits
• To translate this into a logic expression – that is a
combination of our logic operations (NOT, AND and OR) – we
follow this algorithm.
• Identify the row where the outcome (B > A) is 1.
• If input A is 1, write A; otherwise write NOT A in the logic
expression for the selected row.
• If input B is 1, write B; otherwise write NOT B in the logic
expression for the selected row.
• Join these with an AND, and the final equation will be the
sum of all the deduced logic expressions.

Final equation: A’. B

April 16, 2025 TM112-AOU 37


Building logic circuits
• Here, the resulting logic expression NOT A AND B
tells us that the logic circuit that is equivalent to this
truth table for each combination of inputs can be
constructed from two logic gates

• a NOT gate with A as an input, which gives an output of


NOT A
• an AND gate that takes NOT A and B as inputs, which
gives the required result NOT A AND B as an output.

April 16, 2025 TM112-AOU 38


Building logic circuits

In the above circuit:


The output of gate 1 is:
The output of gate 2 is:
The output of gate 3 is:

April 16, 2025 TM112-AOU 39


What is inside a logic gate?
• How Logic gates are actually constructed , and what
exactly is inside a logic gate?
• A Logic gate is itself made up of a combination of more
fundamental components that act as on/off switches.
• In early computers, such devices were generally based
on various designs of vacuum tube (collectively called
valves).
• In modern computers, they are based on transistors,
which are formed of layers of semiconducting material
such as silicon.

A chip containing six inverters


A ‘pluggable’ unit made of valves from
an IBM computer of the mid-1950s
April 16, 2025 TM112-AOU 40

You might also like