Digital Logic & Design
LECTURE 2
SIGNED NUMBERS
Signed Numbers
Computer (digital systems) not only handle
positive numbers but both positive and negative
numbers.
A signed binary number consists of both sign and
magnitude information.
A sign indicates weather a number is positive or
negative .
And the magnitude is the value of the number.
Signed Numbers……
There are three forms in which sign integer ( whole)
number can be represented in binary
a) Sign magnitude form
b) 1's complement
c) 2's complement
Sign bit
Left most bit in a signed, binary number is
the sign bit, which tells you whether the
number is positive or negative.
A “0” sign bit indicates a positive number.
A “1” sign bit indicates a negative number.
a) Sign magnitude form
Sign magnitude form…..
Note:
b)
Select this paragraph to edit
C)
Select this paragraph to edit
Try it
Arithmetic Operations with signed Numbers
How signed number are added ,
subtracted , multiplied and dividend
Arithmetic Operations with Signed 14
Numbers
Four conditions for adding numbers:
1. Both numbers are positive.
2. A positive number with magnitude larger than a
negative number.
3. A negative number with magnitude larger than a
positive number.
4. Both numbers are negative.
Arithmetic Operations with Signed 15
Numbers
Signs for Addition
When both numbers are positive, the sum is
positive.
When the larger number is positive and the smaller
is negative, the sum is positive. The carry is
discarded.
16
Arithmetic Operations with Signed Numbers
Signs for Addition
When the larger number is negative and the
smaller is positive, the sum is negative (2’s
complement form).
When both numbers are negative, the sum is
negative (2’s complement form). The carry bit is
discarded.
i) Both numbers Positive
00000111 7
+00000100 +4
00001011 11
Select this paragraph to edit
Overflow 19
Overflow occurs when number of bits in sum exceeds
number of bits in addend or augend.
Overflow is indicated by the wrong sign.
Occurs only when both numbers are positive or both
numbers are negative
01111101 125
+ 00111010 + 58
_________ ____
10110111 183
Sign Incorrect
Magnitude Incorrect
2) Subtraction
Subtractionis special case of addition .
Already covered in addition.
Done…………
3) Multiplication
The numbers in a multiplication are multiplicand,
the multiplier and product .
Directaddition and partial products are two basic
method for performing signed numbers
multiplication
Multiplication – Direct addition 22
Multiply the signed number
01001101 (multiplicand) and
01001101
00000100(multiplier) using direct
addition method. So the decimal value + 01001101
of multiplier is 4. so multiplicand is 10011010
added to itself four times . + 01001101
11100111
+ 01001101
100110100
Multiplication – Using Partial
Products
Note: Starting From the LSB generate partial products. Shift each partial product by one bit to the left.
Example:
Note:
Convert
last answer
to decimal
and take
last bit
negative in
convetion
i.e
-2343
4) Division
Divide 01100100 by 00011001
100/25 = 4
Example: Divide 01100100 by 00011001
100/25 = 4
Exercise 27
Add 00100001 and 10111100
Subtract 00110010 from 01110111
Multiply 01111111 by10000101
Divide 00110000 by 00001100
Divide 10110000 by 00001100
Hexadecimal Number
Hexadecimal number system has sixteen characters.
The hexadecimal number system consists of digit 0-9 and
letters A-F.
The hexadecimal number has base of sixteen.
It is composed of 16, numeric and alphabetic characters.
Each hexadecimal digit represents 4-bits binary number.
Ten numeric and six alphabetic characters makeup the
hexadecimal number system
Hexadecimal Number System – Base 16
Decimal Binary Hexadecimal
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
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
29
Octal Number
Like the hexadecimal number system, the octal number
system provides a convenient way to express binary
numbers and codes, however, it is used less frequently
than hexadecimal.
The octal number system is composed of eight digits
which are, 0, 1,2,3,4,5,6,7.
The octal number system has a base of 8.
Each octal digit represents a 3 - bits binary number.
Octal Number System – Base 8
Decimal Binary Octal
0 000 0
1 001 1
2 010 2
3 011 3
4 100 4
5 101 5
6 110 6
7 111 7
31
Binary Coded Decimal (BCD)
Binary coded decimal (BCD) is a way to
express each of the decimal digits with a
binary code of 4-bits.
Decimal/BCD conversion
Digital codes
The following are some digital codes
1. Gray codes
2. ASCII codes
3. Unicode
1) Gray codes
Graycode or Reflected binary code is an ordering of
numeral binary system.
The important features of the gray code is that it
exhibits only a single bit change from one word to
the next in sequence.
These were designed originally to prevent spurious
output from electromechanical switches.
Binary no is converted in to Gary code to reduce
switching circuit .
Binary to gray code conversion
There are two steps:
1) MSB in the gray code is same as the MSB in the binary
number.
2) Going from left to right, add each adjacent pair of binary
code to get the next Gray code bit and discard carries.
Select this paragraph to edit
Binary to Gray Code 38
1→ + →0→ + →1→ + →1→ + →0 Binary
↓ ↓ ↓ ↓ ↓
1 1 1 0 1 Gray
Discard Carries
Gray code to binary conversion:
Gray code to Binary 40
1 1 0 1 1 Gray
↓ + ↓ + ↓ + ↓ + ↓
1 0 0 1 0 Binary
Discard Carries
2) ASCII codes:
ASCII is the abbreviation for American standard code for information
interchange .
ASCII is a universally accepted alphanumeric code used in most
computers and other electronic equipment.
Most computer keyboard are standardized with the ASCII.
ASCII has 128 characters and symbols reparented by a 7-bit binary
code .
ASCII can be considered an 8-bit code with the MSB always 0.
Select this paragraph to edit
ASCII codes:
All computer data is just numbers.
Each character of text is stored as a number. When you press a key on
the keyboard, the keyboard sends a number, corresponding to the key
that was pressed.
When text is displayed on your monitor, each character is read from
memory as a number and “drawn” as a glyph (symbolic figure ) on the
display.
ASCII (American Standard Code for Information Interchange) is a
mapping from each character used in American English to a
corresponding number.
Select this paragraph to edit
Assignment # ASCII table
3) Unicode
Unicode is a universal character encoding standard.
It defines the way individual characters are
represented in text files, web pages, and other types
of documents.
Unlike ASCII, which was designed to represent only basic English
characters,
Unicode was designed to support characters from all languages
around the world like European (Latin), Arabic , Chinese, Japanese, Korean,
and other Asian characters
The standard ASCII character set only supports 128 characters,
while Unicode can support roughly 1,000,000 characters.
While ASCII only uses one byte to represent each character,
Unicode supports up to 4 bytes for each character.
Parity Method of Error Detection
A parity bit is a binary digit that indicates whether the number of bits with value
of one in a given set of bits is even or odd. Parity bits are used as the simplest
error detecting code.
Error Detection using Parity Bit
Parity bit can only detect single bit errors (or any odd number of errors).
e.g. 0 0101
even parity bit BCD code
0 0001 bit error