Download presentation
Presentation is loading. Please wait.
Published byJeffry Melton Modified over 9 years ago
1
Chapter 2 Instructions: Language of the Computer Part IIa Number Representation
2
Florida A & M University - Department of Computer and Information Sciences Unsigned Binary Integers Given an n-bit binary number Example 1000 1011 2 = 1×2 7 + 0×2 6 + 0×2 5 1+ 0×2 4 + 1×2 3 + 0×2 2 +1×2 1 +1×2 0 = 128 + 0 + 0 + 0 + 8 + 0 + 2 + 1 = 139 10 Range: 0 to +2 n – 1 4 bits 0-15; 8 bits 0-255 16 bits 0-65,335; 32 bits 0-4,294,967,295
3
Florida A & M University - Department of Computer and Information Sciences Another View 014168256124096 125329512138192 246641010241416384 3871281120481532768 Digit:d7 d6 d5 d4 d3 d2 d1 d0 Position:2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 Weight: 127 64 32 16 8 4 2 1 Convenient Table: Powers of 2
4
Florida A & M University - Department of Computer and Information Sciences A Few Observations (HEX) Given NUM: 1000 1011 4-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 = 1000 1011 8B 8 11 Hex can simplify handling long binary numbers
5
Florida A & M University - Department of Computer and Information Sciences Hexadecimal Base 16 000004010081000C1100 100015010191001D1101 2001060110A1010E1110 3001170111B1011F1111 Example: E B A 8 6 4 2 0 1110 1100 1010 1000 0110 0100 0010 0000 Hex: ECA8 6420
6
Florida A & M University - Department of Computer and Information Sciences More about HEX Given NUM: 1000 1011 = 8B NUM 10 = 8 x 16 1 + B = 8 x 16 + 11 = 128 + 11 = 139 (same as binary)
7
Florida A & M University - Department of Computer and Information Sciences Hex great for long numbers! Given NUM: 1010 0000 1111 0111 NUM 16 = 1010 0000 1111 0111 A0F7 10 0 15 7 NUM 10 = A x 16 3 + 0 x 16 2 + F x 16 1 + 7 = 10 x 16 3 + 15 x 16 + 7 = 10 x 4096 + 240 + 7 = 40960 + 247 = 41,207 Imagine this: 32 bits 8 hex digits!!
8
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: 0000 0010 => 0000 0000 0000 0010 –2: 1111 1110 => 1111 1111 1111 1110
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.