signed numbers l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Signed Numbers PowerPoint Presentation
Download Presentation
Signed Numbers

Loading in 2 Seconds...

play fullscreen
1 / 20

Signed Numbers - PowerPoint PPT Presentation


  • 210 Views
  • Uploaded on

Signed Numbers. Up till now we've been concentrating on unsigned numbers. In real life we have to represent signed numbers ( like: -12, -45, 78). The difference between signed and unsigned numbers is the sign. A scheme is needed to represent the sign as part of the binary representation.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Signed Numbers' - thais


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
signed numbers
Signed Numbers
  • Up till now we've been concentrating on unsigned numbers. In real life we have to represent signed numbers ( like: -12, -45, 78).
  • The difference between signed and unsigned numbers is the sign. A scheme is needed to represent the sign as part of the binary representation.
  • There are a number of schemes for representing signed numbers in binary format.
    • sign-magnitude representation
    • the twos-complement representation.
sign magnitude representation
Sign-Magnitude Representation

In this representation, the leftmost bit of a binary code represents the sign of the value:

  • 0 for positive,
  • 1 for negative;

the remaining bits represent the numeric value.

sign magnitude representation3
Sign-Magnitude Representation

To Compute negative values using Sign/Magnitude (signmag) representation.

Begin with the binary representation of the positive value, then flip the leftmost zero bit.  

sign magnitude representation4
Sign-Magnitude Representation

Ex 1. Find the signmag representation of -610

Step1: find binary representation using 8 bits

610 = 000001102

Step2: if the number is a negative number flip left most bit

10000110

So: -610 = 100001102 (in 8-bit sign/magnitude form)

sign magnitude representation5
Sign-Magnitude Representation

Ex 2. Find the signmag representation of -3610

Step 1: find binary representation using 8 bits

3610 = 001001002

Step 2: if the number is a negative number flip left most bit

10100100

So: -3610 = 101001002 (in 8-bit sign/magnitude form)

sign magnitude representation6
Sign-Magnitude Representation

Ex 3. Find the signmag representation of 7010

Step 1: find binary representation using 8 bits

7010 = 010001102

Step 2: if the number is a negative number flip left most bit

01000110 (no flipping, since it is +ve)

So: 7010 = 010001102 (in 8-bit sign/magnitude form)

sign magnitude representation7
Sign-Magnitude Representation

What is this signmag number?

100000002

The machine will think of it as - 0 , which is a non valid value.

two s complement representation
Two’s Complement Representation
  • Another scheme to represent negative numbers
  • The leftmost bit serves as a sign bit:
    • 0 for positive numbers,
    • 1 for negative numbers.  
two s complement representation9
Two’s Complement Representation

To Compute negative values using two’s Complement representation, begin with the binary representation of the positive value, complement (flip each bit if it is 0 make it 1 and visa versa) the entire positive number, and then add one.

two s complement representation10
Two’s Complement Representation

Ex. Find the two’s complement representation of

–610

Step1: find binary representation in 8 bits

610 = 000001102

two s complement representation11
Two’s Complement Representation

Step 2: Complement the entire positive number, and then add one

00000110

(complemented) -> 11111001

(add one) -> + 1

11111010

So: -610 = 111110102 (in 2's complement form, using any of above methods)

two s complement representation12
Two’s Complement Representation

Alternative method for step 2 

Scan binary representation from right too left, find first one bit, from low-order (right) end, and complement the remaining pattern to the left.

00000110

(left complemented) --> 11111010

two s complement representation13
Two’s Complement Representation

Ex 2: Find the Two’s Complement of -7610

Step 1: Find the 8 bit binary representation of the positive value.

7610 = 010011002

two s complement representation14
Two’s Complement Representation

Step 2:

Find first one bit, from low-order (right) end, and complement the pattern to the left.

01001100

(left complemented) -> 10110100

So: -7610 = 101101002 (in 2's complement form, using any of above methods)

two s complement representation15
Two’s Complement Representation

Ex 3: Find the Two’s Complement of 7210

Step 1: Find the 8 bit binary representation of the positive value.

7210 = 010010002

two s complement representation16
Two’s Complement Representation

Step 2:

Since number is positive do nothing.

So: 7210 = 010010002 (in 2's complement form, using any of above methods)

two s complement representation17
Two’s Complement Representation

The most important characteristic of the two’s-complement system is that the binary codes can be added and subtracted as if they were unsigned binary numbers, without regard to the signs of the numbers they actually represent.

two s complement representation18
Two’s Complement Representation

For example, to add +4 and -3, we simply add the corresponding binary codes, 0100 and 1101:

0100 (+4)

+1101(-3)

0001 (+1)

A carry from the leftmost column has been ignored. The result, 0001, is the code for +1, the sum of +4 and -3.

twos complement representation
Twos Complement Representation

Likewise, to subtract +7 from +3, we add the code for -7, 1001, to that of +3, 0011:

0011 (+3)

+1001(-7)

1100 (-4)

The result, 1100, is the code for -4, the result of subtracting +7 from +3. 

two s complement representation20
Two’s Complement Representation

Benefits of Twos Complements:

  • addition and subtraction simplified in the two’s-complement system,
  • In 8 bits, -0 has been eliminated, replaced by -128, for which there is no corresponding positive number.