Chapter 2 Instructions: Language of the Computer Part IIa Number Representation
Florida A & M University - Department of Computer and Information Sciences Unsigned Binary Integers Given an n-bit binary number Example = 1× × × × × ×2 2 +1×2 1 +1×2 0 = = Range: 0 to +2 n – 1 4 bits 0-15; 8 bits bits 0-65,335; 32 bits 0-4,294,967,295
Florida A & M University - Department of Computer and Information Sciences Another View Digit:d7 d6 d5 d4 d3 d2 d1 d0 Position: Weight: Convenient Table: Powers of 2
Florida A & M University - Department of Computer and Information Sciences A Few Observations (HEX) Given NUM: digit blocks can be written as single digits Hexadecimal base 16 Hex digit represents value of the 4 bits Digits are 0-9, A(10), B, C, D, E, F(15) NUM 16 = 8B 8 11 Hex can simplify handling long binary numbers
Florida A & M University - Department of Computer and Information Sciences Hexadecimal Base C D A1010E B1011F1111 Example: E B A Hex: ECA8 6420
Florida A & M University - Department of Computer and Information Sciences More about HEX Given NUM: = 8B NUM 10 = 8 x B = 8 x = = 139 (same as binary)
Florida A & M University - Department of Computer and Information Sciences Hex great for long numbers! Given NUM: NUM 16 = A0F NUM 10 = A x x F x = 10 x x = 10 x = = 41,207 Imagine this: 32 bits 8 hex digits!!
Florida A & M University - Department of Computer and Information Sciences Sign Extension Representing a number using more bits Preserve the numeric value In MIPS instruction set addi : extend immediate value lb, lh : extend loaded byte/halfword beq, bne : extend the displacement Replicate the sign bit to the left c.f. unsigned values: extend with 0s Examples: 8-bit to 16-bit +2: => –2: =>