Sign Mantissa - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Sign Mantissa

Description:

... 1BA3 Lecture 8. 1. Sign Mantissa. e.g.: 100101012 - -2110. 000101012 ... of values that we can represent with sign mantissa binary numbers (using 8 bits) ... – PowerPoint PPT presentation

Number of Views:92
Avg rating:3.0/5.0
Slides: 11
Provided by: isservice
Category:
Tags: mantissa | sign

less

Transcript and Presenter's Notes

Title: Sign Mantissa


1
Sign Mantissa
We sacrifice 1 bit (MSB) and use it as a flag to
indicate whether the binary number is - or .
e.g. 100101012 -gt -2110 000101012 -gt
2110
What is the range of values that we can represent
with sign mantissa binary numbers (using 8 bits) ?
Answer -127 . . . 127
2
Disadvantages?
Sign bit must be handle differently from the rest
of the binary number during arithmetic operations
100000012 -110 000001012 510
100001102 -610 lt- Wrong!
2 ways of representing the value 0!
000000002 100000002
3
2s Complement
  • The 2s Complement system uses a wrape-arount
    binary number system.
  • 8 bits -gt 256 different values in the range of 0
    . . . 255
  • To represent negative numbers, we let half of
    these numbers be negative, and the other half
    positive.
  • -gt Use Modulo-256 arithmetic

4
This is similar to the clock
If we subtract 4 hours from 2 oclock we get
10 oclock, not -2 oclock
The clock uses a modulo-12 numbering system.
5
This is similar to the clock
To represent -4 in the modulo-12 system we
subtract 4 from 12 to give 8. Why?
4 8 12 4 -4 0 i.e. 0 - 4 -4
12 - 4 8
In modulo-12 system
6
Modulo-256
For modulo-256, (8 bits -gt 28256), to encode a
negative value we subtract the value from 256.
e.g. -4 -gt subtract 4 from 256 252
-4 8 4 -gt 252 8 260
256 4
Note that there is now only 1 way of
representing the value 0.
7
Change the sign of 2s complement
  • How to change the sign of a number in 2s
    comlpement?
  • 1. Invert all the bits in the original binary
    number
  • 2. Add 1 to the number
  • Why?
  • Inverting the bits subtracting the number from
    255
  • But we want to subtract the number from 256
  • -gt Add 1 to the result

8
Example
01101001 -gt 105 1. Invert 10010110 -gt
150 (255 - 105) 2. Add 1 10010110 00000001
10010111 -gt
-105 if 2s complement 151 if positive
(256-105)
9
2s Complement Encoded Binary Numbers
  • Sign of a 2s complement encoded binary is given
    by examing the MSD, just as with sign mantissa
    format.
  • But 2s complement doesnt need any special
    arithmetic rules, unlike sign mantissa.
  • What range of values can be represented with 2s
    complement binary numbers (using 8 bits) ?
  • Answer -128 . . . 127

10
2s Complement in a Reflective Operation
TC(TC(n)) n -gt -(-(n)) n
000000012 -gt 110 1. Invert 111111102 2.
Add 1 111111112 -gt -110 3.
Invert 000000002 4. Add 1
000000012 -gt 110
Write a Comment
User Comments (0)
About PowerShow.com