[go: up one dir, main page]

0% found this document useful (0 votes)
20 views9 pages

Lecture 3

The document discusses the representation of binary numbers in signed and unsigned formats, explaining the differences between them and providing examples for both. It covers various signed number representations including Sign-Magnitude, 1's complement, and 2's complement forms, along with their ranges and examples. Additionally, it introduces Binary Coded Decimal (BCD) codes, BCD addition rules, and other coding schemes like Gray Code and ASCII.
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)
20 views9 pages

Lecture 3

The document discusses the representation of binary numbers in signed and unsigned formats, explaining the differences between them and providing examples for both. It covers various signed number representations including Sign-Magnitude, 1's complement, and 2's complement forms, along with their ranges and examples. Additionally, it introduces Binary Coded Decimal (BCD) codes, BCD addition rules, and other coding schemes like Gray Code and ASCII.
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/ 9

Lecture 3

Signed/Unsigned Numbers and Binary Codes

Binary numbers can be represented in signed and unsigned way. Unsigned binary numbers
do not have sign bit, whereas signed binary numbers uses signed bit as well or these can be
distinguishable between positive and negative numbers.

Unsigned Numbers: Unsigned numbers don’t have any sign, these contain only
magnitude of the number. So, unsigned binary numbers can represent only positive
numbers. For n-bit binary number, the range of unsigned binary number is from
0 to 2𝑛 − 1.

1
Ex 1: Represent decimal number 92 in unsigned binary number.

Simply convert it into binary number, it contains only magnitude of the given number.

(92)10 = (1011100)2

It’s 7 bit binary magnitude of the decimal number 92.

Ex 2: Find range of 5 bit unsigned binary numbers. Also, find minimum and
maximum value in this range.

Range of 5 bit unsigned binary number is from 0 to (25 − 1) which is equal from
minimum value 0 (i.e., 00000) to maximum value 31 (i.e., 11111).

Signed Numbers:

Signed numbers are used specifically to take care of +ve or –ve signs of numbers. Signed
numbers are used to represent both positive and negative numbers. There are three types of
representations for signed binary numbers. These are: Sign-Magnitude form, 1’s
complement form, and 2’s complement form.

Sign-Magnitude Form:

For 𝑛-bit binary number, 1 bit is reserved for sign symbol. If the value of sign bit is 0, then
the given number will be positive, else if the value of sign bit is 1, then the given number
will be negative. Remaining (𝑛 − 1) bits represent magnitude of the number. For n-bit
binary number, the range of signed binary number is from −(2𝑛−1 − 1) to +(2𝑛 − 1).

Ex 3: Represent +𝟗 and −𝟗 using Sign-Magnitude Form with 8-bits

We know that: (9)10 = (1001)2  (9)10 = (0000 1001)2

+9 = (0000 1001)2 −9 = (1000 1001)2

2
1’s complement Form:

In 1’s complement form, positive numbers are represented in simple binary form while
negative numbers are represented by taking their 1’s complement. For n-bit binary
number, the range of signed binary number is from −(2𝑛−1 − 1) to +(2𝑛 − 1).

Ex 4: Represent +𝟗 and −𝟗 using 1’s Complement Form with 8-bits

We know that: (9)10 = (1001)2  (9)10 = (0000 1001)2

+9 = (0000 1001)2 −9 = (1111 0110)2

2’s complement Form:

In 2’s complement form, positive numbers are represented in simple binary form while
negative numbers are represented by taking their 2’s complement. For n-bit binary
number, the range of signed binary number is from −(2𝑛−1 ) to +(2𝑛 − 1).

Ex 5: Represent +𝟗 and −𝟗 using 2’s Complement Form with 8-bits

We know that: (9)10 = (1001)2  (9)10 = (0000 1001)2

+9 = (0000 1001)2 −9 = (1111 0111)2

Representation of 4-bit signed binary numbers using different representations is given as;

3
Note that in computers positive and negative numbers (i.e. signed numbers) are
represented using 2’s complement form.

Binary Codes:

Different coding schemes are available to represent the decimal or binary data.

Binary Coded Decimal Code (BCD Code):

BCD codes are used to represent the decimal numbers specifically. In BCD code, each of
the decimal digit is represented by 4 bit binary code, as per table given below;

4
Note that binary combinations from 1010 to 1111 are not used and have no meaning in
BCD.

Ex 6: Find BCD and binary value of (𝟏𝟖𝟓)𝟏𝟎

To find BCD value, replace each decimal digit with it’s 4-bit BCD value

(185)10 = (0001 1000 0101)2

To find binary value, convert (185)10 to binary by repeatedly dividing with 2 (usual
procedure)

(185)10 = (1011 1001)2

BCD Addition:

Rule for addition of two BCD numbers is given as;

1. When two BCD digits are added, if their sum is greater than or equal to 9 (1001) 2,
add 6 (0110)2 to sum else not.

5
Examples:

Ex 6: Perform the addition of (𝟏𝟖𝟒)𝟏𝟎 + (𝟓𝟕𝟔)𝟏𝟎 in BCD

BCD codes for (184)10 and (576)10 are;

(184)10 = (0001 1000 0100)𝐵𝐶𝐷

(576)10 = (0101 0111 0110)𝐵𝐶𝐷

BCD addition is performed as;

Other Decimal Codes:

Like BCD, there are some other codes which are used to represent the decimal digits from
0 to 9, given as follows;

6
Gray Code:

Gray code is also used to represent the binary numbers, however, their main property is
this that only 1-bit is changed going from given digit to next digit. 4-bit gray code is;

7
ASCII Code:

ASCII is a 7-bit character set containing 128 characters. It contains the numbers from 0-9,
the upper and lower case English letters from A to Z, and some special characters. The
character sets used in modern computers, in HTML, and on the Internet, are all based on
ASCII. ASCII codes are shown below;

8
9

You might also like