viⅷi Contents 2.1.3 Addressing and Byte Ordering 42 2.1.4 Representing Strings 49 2.1.5 Representing Code 49 2.1.6 Introduction to Boolean Algebra 50 2.1.7 Bit-Level Operations in C 54 2.1.8 Logical Operations in C 56 2.1.9 Shift Operations in C 57 2.2 Integer Representations 59 2.2.1 Integral Data Types 60 2.2.2 Unsigned Encodings 62 2.2.3 Two's-Complement Encodings,64 2.2.4 Conversions between Signed and Unsigned 70 2.2.5 Signed versus Unsigned in C 74 2.2.6 Expanding'the Bit Representation of a Number 76 2.2.7 Truncating Numbers 81 2.2.8 Advice on Signed versus Unsigned 83 2.3 Integer Arithmetic 84 2.3.1 Unsigned Addition 84 2.3.2 Two's-Complement Addition 90 2.3.3 Two's-Complement Negation 95 2.3.4 Unsigned Multiplication 96 2.3.5 Two's-Complement Multiplication 97 2.3.6 Multiplying by Constants 101 2.3.7 Dividing by Powers of 2 103 2.3.8 Final Thoughts on Integer Arithmetic 107 2.4 Floating Point 108 2.4.1 Fractional Binary Numbers 109 2.4.2 IEEE Floating-Point Representation 112 2.4.3 Example Numbers 115 2.4.4 Rounding 120 2.4.5 Floating-Point Operations 122 2.4.6 Floating Point in C 124 2.5 Summary 126 Bibliographic Notes 127 Homework Problems 128 Solutions to Practice Problems 143 3 Machine-Level Representation'of Programs 163 3.1 A Historical Perspective 166viii Contents 2.1.3 Addressing and Byte Ordering 42 2.1.4 Representing Strings 49 2.1.5 Representing Code 49 2.1.6 Introduction to Boolean Algebra 50 2.1.7 Bit-Level Operations in C 54 2.1.8 Logical Operations in C 56 2.1.9 Shift Operations in C 57 2.2 Integer Representations 59 2.2.1 Integral Data Types 60 2.2.2 Unsigned Encodings 62 2.2.3 1\vo's-Complement Encodings, 64 2.2.4 Conversions between Signed and Unsigned 70 2.2.~ Signed versus Unsigned inC 74 2.2.6 Expanding"the Bit Representation of a Number 76 2.2.7 Truncating Numbers 81 2.2.8 Advice on Signed versus Unsigned 83 2.3 Integer Arithmetic 84 2.3.1 Unsigned Addition 84 2.3.2 1\vo's-Complement Addition 90 2.3.3 1\vo's-Complement Negation 95 2.3.4 Unsigned Multiplication 96 2.3.5 1\vo's-Complement Multiplication 97 2.3.6 Multiplying by Constants 101 2.3.7 Dividing by Powers of 2 103 2.3.8 Final Thoughts on Integer Arithmetic 107 2.4 Floating Point 108 2.4.1 Fractional Binary Numbers 109 2.4.2 IEEE Floating-Point Representation 112 2.4.3 Example Numbers 115 2.4.4 Rounding 120 2.4.5 Floating-Point Operations 122 2.4.6 Floating Point in C 124 2.5 Summary 126 3 Bibliographic Notes 127 Homework Problems 128 Solutions to Practice Problems 143 Machine-Level Representatioll'of Progralhs 163 3.1 A Historical Perspective 166 -- - . •