0 index
1 Sign/magnitude notation
2 Examples:
3 Ones Complement
4 Adding Negative Numbers
5 Try another
6 PAUSE
7 Compare
8 Floating Point
9 Binary
10 Conversion table (floating pt.)
11 Examples:
12 Errors
13 Do the math
14 Convert back
15 Normalized form
16 Scientific notation
17 Floating point
18 Example

outline
created using slideshow.cgi by Andy Harris















CSCI N301 Fundamental CS Concepts: n301/cs05othernum
1. Sign/magnitude notation
  • Binary digits can be used to represent not only whole numbers but also other forms of data, including signed integers, decimal numbers and characters.
  • To represent signed integers, we can use the leftmost bit to represent the sign, 0 meaning + and 1 meaning -



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
2. Examples:
  • The number –49 would be represented as:
    1  110001
    -    49
  • What about the binary number 1000000 and the binary number 0000000?



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
3. Ones Complement
  • Possible solution to the problem
  • The names comes from the fact that it is obtained by subtracting each digit of the input number from 1
  • However, two’s complement is the better solution – this is when 1 is added to the ones-complement



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
4. Adding Negative Numbers
  • Let’s calculate: 4 + (-6) using twos complement:
     - 8   4  2  1 
     0  1  0  0 
     1  0  1  0 



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
5. Try another
  • Calculate 5 + (-2) in binary



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
6. PAUSE
  • Pause the tape to do the calculation. When done, come back to see how it is done.



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
7. Compare
  • Is 10 the same as 110?



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
8. Floating Point
  • Also known as scientific notation
  • The number 1,023,48710 is 1.023487 * 106
  • The number 0.102348710 is 1.023487 * 10-1



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
9. Binary
  • The number 101001001112 is 1.0100100111 * 210
  • The number .00112 is .11 * 2-2



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
10. Conversion table (floating pt.)
  •  1/2  1/4  1/8  1/16  1/32 
     .5 .25.125.0625.03125
              



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
11. Examples:
  • Convert .625 into binary
    .625 * 2 = 1.250 (extract the 1)
    .250 * 2 = 0.500 (extract the 0)
    .500 * 2 = 1.000 (extract the 1)
  • The digits extracted are taken in the order extracted. In this case, the result is .101 (1/2 + 1/8 = 5/8 = .625)



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
12. Errors
  • One source of errors is converting back and forth between decimal and binary
  • Example:
    calculate .6 + .6
    first convert to binary .6
    .1001100110011……



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
13. Do the math
  • Find the sum
        .10011001
      +.10011001
      1.00110010



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
14. Convert back
  • So, 1.00110010 converts to 1 + 1/8 + 1/16 + 1/128 = 1.195 (actual sum = 1.2)
  • Error = 1.2 – 1.195 = .005 due to round off error made during conversions



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
15. Normalized form
  • In normalized form the leading 1 appears next to the decimal point.
  • Example:
    .11001001



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
16. Scientific notation
  • Avagadro’s number: Na = 6.022 * 10 23



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
17. Floating point
  • A BBBB C DD form (8 bits)
  • A = sign of the mantissa | BBBB = mantissa | C = sign of the exponent | DD = exponent
  • Example:
    +.1011 * 2+3
    0 | 1011 | 0 | 11



































CSCI N301 Fundamental CS Concepts: n301/cs05othernum
18. Example
  • sign
    of
    mantissa
    sign
    of
    exponent
    ABBBBCDD
    digits
    of
    mantissa
    digits
    of
    exponent



































outline

Sign/magnitude notation

Examples:

Ones Complement

Adding Negative Numbers

Try another

PAUSE

Compare

Floating Point

Binary

Conversion table (floating pt.)

Examples:

Errors

Do the math

Convert back

Normalized form

Scientific notation

Floating point

Example