L07 - CS 61C L07 Number Representation (1) Wawrzynek Fall...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 61C L07 Number Representation (1) Wawrzynek Fall 2007 UCB 9/12/2007 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS61C Machine Structures Lecture 7 Number Representation CS 61C L07 Number Representation (2) Wawrzynek Fall 2007 UCB Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 ) CS 61C L07 Number Representation (3) Wawrzynek Fall 2007 UCB Numbers: positional notation Number Base B B symbols per digit: Base 10 (Decimal): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 2 (Binary): 0, 1 Number representation: d 31 d 30 ... d 2 d 1 d 0 is a 32 digit number value = d 31 x B 31 + d 30 x B 30 + ... + d 2 x B 2 + d 1 x B 1 + d x B Binary: 0,1 (In binary digits called bits) 1011010 = 1x2 6 + 0x2 5 + 1x2 4 + 1x2 3 + 0x2 2 + 1x2 + 0x1 = 64 + 16 + 8 + 2 = 90 Notice that 7 digit binary number turns into a 2 digit decimal number A base that converts to binary easily? CS 61C L07 Number Representation (4) Wawrzynek Fall 2007 UCB Which base do we use? Decimal: great for humans, especially when doing arithmetic Hex: if human looking at long strings of binary numbers, its much easier to convert to hex and look 4 bits/symbol Terrible for arithmetic on paper Binary: what computers use; you will learn how computers do +,-,*,/ To a computer, numbers always binary Regardless of how number is written: 32 10 == 0x20 == 100000 2 Use subscripts ten, hex, two in book, slides when might be confusing CS 61C L07 Number Representation (5) Wawrzynek Fall 2007 UCB Hexadecimal Numbers: Base 16 Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Normal digits + 6 more from the alphabet In C, written as 0x (e.g., 0xFAB5) Conversion: Binary Hex 1 hex digit represents 16 decimal values 4 binary digits represent 16 decimal values 1 hex digit replaces 4 binary digits One hex digit is a nibble . Two is a byte Example: 1010 1100 0011 (binary) = 0x_____ ? CS 61C L07 Number Representation (6) Wawrzynek Fall 2007 UCB Decimal vs. Hexadecimal vs. Binary Examples: 1010 1100 0101 (binary) = AC5 (hex) 10111 (binary) = 0001 0111 (binary) = 17 (hex) 3F9(hex) = 11 1111 1001 (binary) How do we convert between hex and Decimal? 00 0 0000 01 1 0001 02 2 0010 03 3 0011 04 4 0100 05 5 0101 06 6 0110 07 7 0111 08 8 1000 09 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 CS 61C L07 Number Representation (7) Wawrzynek Fall 2007 UCB What to do with representations of numbers?...
View Full Document

This note was uploaded on 04/09/2008 for the course CS 61A taught by Professor Harvey during the Spring '08 term at University of California, Berkeley.

Page1 / 13

L07 - CS 61C L07 Number Representation (1) Wawrzynek Fall...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online