Storing Integers and Fractions
1 Storing Integers Two’s complement notation The most popular means of representing integer values
Figure 1.21 Two’s complement notation systems
Figure 1.23 Addition problems converted to two’s complement notation
2 Storing Fractions Floating-point notation In contrast to the storage of integers, the storage of a value with a fractional part requires that we store not only the pattern of 0s and 1s representing its binary representation but also the position of the radix point. A popular way of doing this is based on scientific notation and is called floating-point notation.
2 Storing Fractions Scientific notation: Floating-point notation consists two fields: the exponent field (阶码)and the mantissa field (尾数) Single precision floating point: 32bits, a precision of 7 decimal digits; Double precision floating point: 64bits, a precision of 15 decimal digits
Figure: The storage of Single precision floating point exponent field (1byte) mantissa field (3bytes) sign of exponent (阶符) exponent (阶码) sign of mantissa (数符) mantissa (尾数) 1bit 7bit 23bit 0000101 11010100000000000000000 26.5=11010.1=+0.110101×2+5 N=数符×尾数×2 阶符×阶码
3 Hexadecimal Notation Hexadecimal notation A shorthand notation for long bit patterns Divides a pattern into groups of four bits each Represents each group by a single symbol Example: (10100011)B becomes (A3)H Example: (0.1101011)B becomes (0.D6)H
Figure 1.6 The hexadecimal coding system
4 Octal Notation Octal notation Example: (10100011)B becomes (243)O Divides a pattern into groups of three bits each Represents each group by a single symbol Example: (10100011)B becomes (243)O Example: (0.1101011)B becomes (0.654)O
Figure: Relationship among four kinds of coding system decimal binary octal hexadecimal 0 0000 000 0 1 0001 001 1 2 0010 002 2 3 0011 003 3 4 0100 004 4 5 0101 005 5 6 0110 006 6 7 0111 007 7 8 1000 010 8 9 1001 011 9 10 1010 012 A 11 1011 013 B 12 1100 014 C 13 1101 015 D 14 1110 016 E 15 1111 017 F 16 10000 020 10
4 Octal Notation Summary Two’s complement notation Floating-point notation Hexadecimal notation Octal notation