0% found this document useful (0 votes)
1K views13 pages

Class 11 Data Representation Notes

1. Computers store data using electronic circuits that can be either on (1) or off (0), representing binary digits. 2. Binary uses combinations of 1s and 0s to represent data values according to their place values, from 128 to 1. 3. Two's complement representation allows binary to store both positive and negative numbers, with the most significant bit representing the sign (0 is positive, 1 is negative).

Uploaded by

Sour XD
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)
1K views13 pages

Class 11 Data Representation Notes

1. Computers store data using electronic circuits that can be either on (1) or off (0), representing binary digits. 2. Binary uses combinations of 1s and 0s to represent data values according to their place values, from 128 to 1. 3. Two's complement representation allows binary to store both positive and negative numbers, with the most significant bit representing the sign (0 is positive, 1 is negative).

Uploaded by

Sour XD
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

9618 – Chapter 1 Notes

1.1 Data Representation

Computers are made up hardware that stores and processes data. If you break a
computer down into its most basic components you have millions of circuits that
either allow electricity to flow, or not. The computer uses electronic circuits to store
one of two values using a switch – the switch is
either ON (1) or OFF (0).

Using a number of these switches provides us with many possible combinations of


1s and 0s which we can use to represent
data values. This is called Binary.

Denary: A system of numbers using ten digits, 0 and 1-9 (also called base-10
system)
Binary: A system of numbers using only 2 bits, 0 and 1 (also called base-2 system)

Binary place values

27 26 25 24 23 22 21 20

Binary to Denary

To convert the binary 111001 into a denary number, use the place values.

Add the place values that are turned ON (1) to get the denary result.
The number is 32+16+8+1 = 57
Denary to Binary
Let’s convert 57 into binary: (Use the same place values.)

• Turn OFF all the place values that are greater than the given number.
(In this case turn OFF 128 and 64)

128 64 32 16 8 4 2 1
0 0

• Turn ON the value that is smaller equal to given value

128 64 32 16 8 4 2 1
0 0 1

• Write a 1 under the column heading 32. That leaves us with 57-32 = 25.
Write a 1 under the column heading 16 (because we can take 16 out of
25. 25-16 leaves 9) You should be able to see now that 9 is an 8 and a 1 so we
end up with:
Always double check by adding the columns up at the end. They should give
you the given number

128 64 32 16 8 4 2 1
0 0 1 1 1 0 0 1

Max and range


They are not the same thing. Consider the following example: If I were
to have 3 binary digits, the maximum value that I could store would be
1112, this equates to 4 + 2 + 1 = [Link] I
were to be asked, the range of numbers Test Yourself
then we have 8 options:
What will be min, max and range
Min 000 of 12 bits?
001 Min:
010
011 Max:
8 set of values - RANGE
100 Range:
101 Formula for Range
110 2𝑛
Max 111 Where n is number of bits
Signed Integer

The pure binary Conversion that we have studied before can only represent positive
integers as the min number that they can represent is 0. And hence it can be used
for unsigned integers. So, how can computer represent negative numbers?

One’s complement and two’s complement are two important binary concepts. Two’s
complement is especially important because it allows us to represent signed
numbers in binary, and one’s complement is the interim step to finding the two’s
complement.

Two’s complement also provides an easier way to subtract numbers using addition
instead of using the longer, more involving subtraction method

One’s Complement
Two’s Complement

The two’s complement is a method for representing positive and negative integer values in binary.
The useful part of two’s complement is that it automatically includes the sign bit.

Finding Two’s Complement of a Denary Value:

Method 1

Positive Integer Negative Integer

Use pure binary conversion add 1 to the one’s complement.

Example: -23 (negative integer)

Step1: Find 23 binary value 00010111


Step 2: invert each bit 11101000
Add these binary values
Step 3: Add +1 to step 2 00000001

11101001  two’s complement value

Method 2: (use and learn this method)

The MSB (the left most bit) still represents a number but is assumed to be
negative. This means that place values, become:

-128 64 32 16 8 4 2 1

-128 64 32 16 8 4 2 1
0 1 1 1 0 1 0 1

28

-128 64 32 16 8 4 2 1
1 0 0 0 1 0 1 1
Two’s Complement Method 2 tips:

When the number is negative always turn ON MSB which has negative place value,
and use this equation

-128 + X = required negative value


Where X represent all the positive place values

Example: -73

-128 64 32 16 8 4 2 1
1

It’s a negative number so X


turn ON -128 (MSB)

-128 + X = -73
X = 128-73
X = 55

-128 64 32 16 8 4 2 1
1 0 1 1 0 1 1 1

55

• In two’s complement the binary value with 0 as MSB is positive value,


and 1 as MSB is negative.

001011 → Positive
100110 → Negative
Twos Complement Binary to Denary

Add all the place values that are turned ON (1)

-128 64 32 16 8 4 2 1
0 1 1 0 0 1 1 0
NOTE: Whenever
64+32+4+2 = 102 MSB is ON the answer
comes as negative
denary value
-128 64 32 16 8 4 2 1
1 0 1 1 0 1 0 1

-128+32+16+4+1 = -75

Two’s Complement Max and Min:

Min for 8-bit -128 64 32 16 8 4 2 1


register: -128 1 0 0 0 0 0 0 0

Max for 8-bit -128 64 32 16 8 4 2 1


register: +127 0 1 1 1 1 1 1 1

Note that the range of possible integers represented by one byte is now -128 to
+127.

Two’s complement has the major advantage that addition and subtraction of two
numbers in two’s complement form produces the correct result – as long as the
result is within the permitted range of possible number of bits.
Binary Addition & Subtraction

The binary number system uses only two digits 0 and 1 due to which their addition
is simple. There are four basic operations for binary addition, as mentioned above.

Carry Sum
0+0 0
0+1 1
1+1 1 0
1+1+1 1 1

The column by column addition of binary is applied below in details.

Overflow:
If the result of an arithmetic operation is to too large (positive or negative) to fit into
the resultant bit-group, then arithmetic overflow occurs

Digital systems usually operate on a fixed number of bits. Addition is said


to overflow if the result is out of range of available bits (too big to fit in the available
bits). A 4-bit number, for example, has the range [0, 15]. 4-bit binary
addition overflows if the result exceeds 15. The fifth bit is discarded, producing an
incorrect result in the remaining four bits. Overflow can be detected by checking
for a carry out of the most significant column.

Compute 11012 + 01012. Does overflow occur?

Solution shows the sum is 100102. This result overflows the range
of a 4-bit binary number. If it must be stored as four bits, the most
significant bit is discarded, leaving the incorrect result of 00102. If
the computation had been done using numbers with five or more
bits, the result 100102 would have been correct.

Overflow bit
Remember: −2n−1 ≤ Two's Complement ≤ 2n−1 − 1

−8 ≤ 4 bit ≤ +7

−128 ≤ 8 bit ≤ +127

If 2 Two's Complement numbers are added, and they both have the same sign
(both positive or both negative), then overflow occurs if and only if the result has the
opposite sign. Overflow never occurs when adding operands with different signs.

i.e. Adding two positive numbers must give a positive result


Adding two negative numbers must give a negative result

Overflow occurs if

• (+A) + (+B) = −C
• (−A) + (−B) = +C

Example: Using 4-bit Two's Complement numbers (−8 ≤ 4 bits ≤ +7)

(−7) 1001
+(−6) 1010
------------
(−13) 1 0011 = 3 Overflow (largest −ve number is −8)

Binary Subtraction

Borrow Method:

Remember 10 in
binary is 2
Twos Complement Method:
NOT means taking
Case1: When binary value is given (like in above figure)
complement
B1 – B2 = B1 + (NOT(B2) +1) /Inverse of each
bit

Solving the same problem using this method

1100–1010
1 1 0 0 + (NOT(1 0 1 0) + 1)
1 1 0 0 + (0 1 0 1 + 1)
1 1 0 0 + (0 1 1 0)

1 1 0 0
+ 0 1 1 0
1 0 0 1 0

Discard this bit

Case2: When denary value is given

D1 – D2 = B1 + (- D2)
Convert -D2 to binary using 2’s complement

55 – 20 = 55 + (-22)
Binary Coded Decimal

Binary Coded Decimal (BCD) is a system of writing


numerals (0-9) in binary using only 4 bits

Denary to BCD:

Each digit is changed into a four-bit binary number that is


then placed after one another in sequence.

For example, to convert 398 into BCD,


we convert the
3 to 0011,
9 to 1001
8 to 1000.
Thus, in BCD, 398 is represented by 001110011000.

BCD to Denary:

Divide the binary pattern in group of 4 bits starting from right hand side

0110 1001 0100

6 9 4

Describe practical applications where BCD is used

Some numbers are not proper numbers because they don’t behave like numbers.
For example, a barcode looks like a number but if the barcode for a chocolate bar
is added to the barcode for a sponge cake the result is meaningless. Values that
are written as a string of digits but do not behave like numbers are often stored in
binary coded decimal (BCD)

BCD code is useful for outputting to displays that are always numeric (0 to 9), such
as those found in digital clocks or digital voltmeters.
Hexadecimal System

Hexadecimal system is base 16 system that was developed for humans, as they
are not very good at remembering long strings of numbers or to say binary values
so, to make it easier for us, we can represent every group of 4 bits with a single
hexadecimal digit.

1 Hex digit = 4 bits = 1 nibble

The smallest value you can have with 4 bits is 0000 = 0.


The largest value is 1111= 15. In base 10 we have 10
symbols 0 to 9, if we use the 16 symbols for 0 to 15 we
can use a system based on place values of 16 rather
than 2 or 10. We call this hexadecimal (or hex for short).
We do, however need to have symbols for the numbers
10, 11, 12, 13, 14 and 15. We use the letters A, B, C, D, E
and F to represent these values.

Binary to Hexadecimal

To convert from Binary to Hex you first need to divide the binary value from right
hand side into group of 4 bits.
Hexadecimal to Binary

Hexadecimal to Denary
Convert Hexadecimal to Binary and Binary to Denary

Denary to Hexadecimal
Convert denary to binary and binary to hexadecimal
Byte: a group of eight bits treated as a single unit
Nibble: a group of four bits.

Decimal Prefix vs Binary Prefix

Common questions

Powered by AI

Binary is a base-2 system using only digits 0 and 1, while hexadecimal is a base-16 system using digits 0-9 and letters A-F. To convert from binary to hexadecimal, the binary number is divided into groups of four bits (nibbles) starting from the right. Each nibble is then converted to a single hexadecimal digit . Conversely, each hexadecimal digit can be converted to a corresponding 4-bit binary sequence. These conversions allow for more human-readable binary values .

To find the two's complement of a given denary number, first convert the absolute value to binary. Then, invert each bit to obtain the one's complement, and finally add 1 to this result to obtain the two's complement . This method is vital for representing signed integers in binary, as it allows both positive and negative values to be encoded and facilitates straightforward arithmetic operations like addition and subtraction .

Moving from unsigned to signed integer representation in binary reduces the non-negative range while introducing negative numbers. For example, in an 8-bit system, unsigned integers range from 0 to 255. In contrast, signed integers using two's complement range from -128 to +127. This is because the MSB in the signed representation contributes a negative weight .

Hexadecimal representation is preferred because it compactly represents binary data and is easier for humans to read and understand. Each hexadecimal digit corresponds to a 4-bit binary sequence, reducing long binary strings to manageable sizes. This compact representation is particularly useful in programming and debugging where readability and space are concerns .

The BCD system represents each decimal digit independently as a four-bit binary number, unlike a pure binary representation that encodes an entire number as a binary value. BCD is preferred in applications where exact decimal representation is necessary, such as digital clocks and numeric displays, because it avoids binary conversion errors and simplifies input and output processes .

The two's complement system allows for both addition and subtraction using addition operations alone, by automatically including the sign bit. Overflow occurs in two's complement representation when the result of an arithmetic operation cannot be represented within the fixed number of bits. This happens because the system interprets the most significant bit as negative. For a fixed bit size, overflow happens if two positive numbers yield a negative result or two negative numbers yield a positive result .

Arithmetic overflow in fixed bit digital systems occurs when the result of an operation exceeds the maximum representable value for the given bit length. This often results in incorrect computations, such as a positive result becoming negative or vice versa. System checks for overflow by detecting a carry out of the most significant bit. In practical terms, this can lead to significant errors in computations, especially in systems where precision is critical, like financial calculations or embedded systems .

In the two's complement binary system, the Most Significant Bit (MSB) serves as the sign bit. If the MSB is 0, the number is positive, and if it's 1, the number is negative. This inherent design results from the MSB being valued as a negative power of two, which adjusts the number's overall value to represent signed integers .

To convert a binary number to a denary (decimal) number, you sum the products of each bit value (0 or 1) with its corresponding place value (powers of two). For example, converting the binary number 111001 to denary involves adding 32, 16, 8, and 1, which are the place values where the bit is 1. Thus, 111001 in binary equals 57 in denary .

Overflow in binary arithmetic occurs when the result of an addition or subtraction exceeds the maximum (or minimum) value that can be held in the fixed number of bits. In unsigned binary, overflow is detected by a carry out of the MSB. In signed binary operations using two's complement, overflow is detected if two numbers with the same signs yield a result with a differing sign .

You might also like