Number Systems: Negative Integers and Floating Point - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Number Systems: Negative Integers and Floating Point

Description:

– PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 21
Provided by: Dale143
Category:

less

Transcript and Presenter's Notes

Title: Number Systems: Negative Integers and Floating Point


1
??? ???? ??? ????? ????? ????? ?? ????????
  • ??????? ???? ?? ? ??????????

2
????? ?????
  • ????? ?? ???? ???????? ??? ????? ????? ?????
  • ?? ??? ?? ???? ????? ???????? ?? 10 ????? ???? ??
    ???
  • ?????????? ?? ????? ?? ???? ??????? ?? ????
  • ??? ????? ?? ????? ?? ??? ????? ???? ????? ????
    ???
  • ?? ??? ?? ???? ?? ??? ??? ?? ?? ??? ?? ?? ???
    ??? ????
  • bit binary digit
  • Byte 8 bits
  • ??????? ????? ???? ?? ????? ?? ??? ????

3
????? ????? ????
  • Unsigned Integers
  • Binary form,
  • Useful for non-negative data
  • Characters, Ages, Date,
  • Examples 5 in 8 bits is 0000 0101
  • N bits hold range 0.. 2N -1
  • Signed Integers
  • Sign Bit
  • Twos Complement

4
Negation By Sign bit
sign 1 bit
Number, 7bits
  • Examples 52 0000 0101 , -52 1000 0101
  • N bits Range -2N-1 -1... 2N-1 -1
  • Problems
  • 1000 0000 0 0000 0000
  • Special algorithm for subtraction

5
???? 2
  • Twos complement of a kbits binary number, N, is
    2k - N .
  • Examples 2s comp of 5 in 8 bits is 28 - 5 251
  • 5 0000 0101
  • 251 1111 1011
  • Simple conversion Logically NOT the number, then
    add a 1 .

6
???? 2
  • ???? 2 ??? k ???? N ????? ??? ??2k N
  • ????
  • comp(5) 28 - 5 251
  • 5 0000 0101? comp(5) 251 1111 1011
  • comp(128) 1000 0000 256 128 128
  • ???? ?????? ???? 2
  • ?????? ??? ?? ?? ?? ? ?????? ?? ?? ?? ??? ?????
    ?? ????
  • ??? ???? ?? ?? (1) ??? ?? ????

7
???? 2
  • ??? ?? ???????
  • ????? ???? ?? ???? ???? 2 ????? ?? ????.
  • ??????? ??? ????? ????? ??? ??? ????? ?? ???.
  • ??? ??????? ??? ?? ????? ???? ????? ????? ??? ???
  • ??? ?? ???? ? ??? ???? ???
  • ?? ???? ??? ?????? ??? ??? ?? ?????? ??? ??? ???
    ???? ? ???? ???? ????? ????? ????

8
????? ?????? Fractional Numbers
  • Examples 456.7810 4 x 102 5 x 101 6 x 100
    7 x 10-18 x 10-2
  • 1011.112 1 x 23 0 x 22 1 x 21 1 x 20
    1 x 2-1 1 x 2-2
  • 8 0 2 1
    1/2 ¼
  • 11 0.5 0.25 11.7510
  • ????? ?? ????? 2 ?? ????? 10
  • Examples 111.112 1 x 22 1 x 21 1 x 20
    1 x 2-1 1 x 2-2
  • 4 2 1 1/2
    ¼ 7.7510
  • Examples 11.0112

9
????? ????? 10 ?? ????? 2
  • Examples 7.7510 (?)2
  • Conversion of the integer part repeated division
    by 2
  • 7 / 2 3 (Q), 1 (R) ? 3 / 2 1 (Q), 1 (R) ?
    1 / 2 0 (Q), 1 (R) 710 1112
  • Conversion of the fractional part perform a
    repeated multiplication by 2 and extract the
    integer part of the result
  • 0.75 x 2 1.50 ? extract 1
  • 0.5 x 2 1.0 ? extract 1
    0.7510 0.112
  • 0.0 ? stop
  • ? Combine the results from integer and
    fractional part, 7.7510 111.112
  • How about choose some of
  • Examples try 5.625B

4
2
1
1/2
1/4
1/8
0.25
0.125
0.5
10
????? ??????
  • Exercise 1 Convert (0.625)10 to its binary
    form
  • Exercise 2 Convert (0.6)10 to its binary form
  • Solution

Solution 0.625 x 2 1.25 ? extract 1 0.25 x
2 0.5 ? extract 0 0.5 x 2 1.0 ? extract 1
0.0 ? stop ? (0.625)10 (0.101)2
11
????? ??????
  • Exercise 3 Convert (0.8125)10 to its binary
    form

Solution 0.8125 x 2 1.625 ? extract 1
0.625 x 2 1.25 ?
extract 1 0.25 x 2 0.5 ? extract 0 0.5 x 2
1.0 ? extract 1 0.0 ? stop ? (0.8125)10
(0.1101)2
12
????? ????? ??????
  • ??? x ???? ?????? ????? ????? ????? ?? ???? ???
  • x f Base E
  • f mantissa(??????)
  • E exponent(???)
  • Example 125.3210 0.12532 103
  • mantissa
  • - 125.3210 - 0.12532 103
  • 0.054610 0.546 10 1
  • ?????? ?? ???? ????? ???? ???? ?? ???. ??? ?? ???
    ?????? ??? ??? ?? ??? ????? 1 ???? ??? ??? ???
    ??? ???

13
????? ???? ?????
  • Example
  • 134.1510 0.13415 x 103
  • 0.002110 0.21 x 10-2101.11B .1011 x 23 or
    1.011 x 22 (hidden1)0.011B .11 x 2-1 or 1.1 x
    2-2 (hidden1)AB.CDH .ABCD x 162
  • 0.00ACH .AC x 16-2

14
????? ????? ??????
  • ??? ?? ????? 16 ???? ???? ????? ????? ??? ?????
    ?????? ??????? ??????? ?? ?? ????
  • ????? ??? ???? ????? ????? ??? ??? ( 0 ???? ? 1
    ????)
  • 11 ??? ???? ???? ????? ??? ????? ?????? ?????.(
    (f
  • ???? ??? ????? ???? ????? ???? ??? ?? ????? 7 ???
    (E). ???? ???? ??? ????? ???? ?? ??? ???207
    (0111). 218 (1000), 2-16 (0110)

x f Base E
f 1.?1?2?3?4?11 ?12?15
E converted to binary, b1b2b3b4
LSB
MSB
0 - 1
Excess-7
15
????
  • ????? ??? 1110.111010111111 ?? ????????
  • ??? ??? ????? ????
  • 1110.111010111111
  • 1.110111010111111 2 3
  • ??? ??? ?????? ??? 1073
  • ????? 16 ???? 0 11011101011 1010

16
???? ????? ?????
  • ??? 0110 0000 0000 0100 B ?? ??? ????? ???. ???
    ???? ?? ?????
  • 0 11000000000 0100 B
  • 1.11B 2(4-7)-3 0.00111B
  • 7/32 0.21875D

17
IEEE 754 Standard
  • ??? ????????? ?? ???? ?????????? ???? ??????? ???
  • ??? ?????? ?? ??? float ????? 32 ??? ???
  • ??? ????? ???? ????? ????? ??? ??? ( 1 ???? ?
    ??? ????)
  • 23 ??? ??????? ???? ????? ?????? ??? ?? ?? ????
    ????? ?? ???? ???. ???? ??? ?? ??? ?? ???? ??
    ???? ???? ??? ???
  • 8 ??? ?????? ???? ??? ?? ???? ?? ??? ?? ??? 127
    ?? ?? ????? ??? ???.
  • ????? ?????? double ?? ???? ?????? ??????? ??
    ????

18
IEEE 754 Standard
  • ????? ???
  • ??? ??? ? ?????? ??? ?????? ??? ??? ???
  • ??? ??? ??? ????? 1 ???? ??????? ??? ???
  • ??? ??? ?????? ????? ??? ?? ????? ???? ? ??????
    ??? ????? ??? ?? ????? ???
  • ??? ??? ?????? ????? ??? ?? ????? ???? ? ??????
    ??? ??? ????? ??? ????? ???? ??? NaN Not a
    Number

19
IEEE 754 Standard
  • IEEE 754 Examples Normalized Numbers
  • 0 1000 0011 0000 0000 0000 0000 0000 000
  • 1 x 24 16
  • 0 0011 0001 0000 0000 0000 0000 0000 000
  • 1 x 2-78 3.3087e-24
  • 0 1000 0001 0100 0000 0000 0000 0000 000
  • 1.25 x 22 5

20
?????
  • ??? ???? ??? ???? ? ????? ???? ?? ???? C/JAVA
    ????? ??? ?
Write a Comment
User Comments (0)
About PowerShow.com