lecture2

lecture2 - CS 64 Lecture 2 Data Representation Reading: FLD...

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

View Full Document Right Arrow Icon
1 CS 64 Lecture 2 Data Representation Reading: FLD 1.2-1.4 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) 1010 10 ?= 1010 2 ?=
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 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 0 x B 0 Binary: 0,1 1011010 = 1x2 6 + 0x2 5 + 1x2 4 + 1x2 3 + 0x2 2 + 1x2 + 0x1 = 64 + 16 + 8 + 2 = 90 An Example The number 2001 A base that converts to binary easily?
Background image of page 2
3 Anything Wrong with This Picture? Hexadecimal Numbers: Base 16 Hexadecimal: 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F 0xEDF… Conversion: Binary  Hex 1 hex digit represents 16 decimal values 4 binary digits represent 16 decimal values => 1 hex digit replaces 4 binary digits Examples: 1010 1100 0101 (binary) = ? (hex) 10111 (binary) = 0001 0111 (binary) = ? 3F9(hex) = ? (binary)
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Octal Numbers: Base 8 0,1,2,3,4,5,6,7 Conversion: Binary  Octal 1 octal digit represents 8 decimal values 3 binary digits represent 8 decimal values => 1 octal digit replaces 3 binary digits Examples: 1010 1100 0101 (binary) = ? (oct) How to convert Octal  Hex Conversion from One to Another(1)
Background image of page 4
5 Conversion from One to Another(2) Examples of octal-to-binary and hexadecimal-to- binary conversion. Exercise I 1010 1100 0101 (binary) = ? (hex) 10111 (binary) = 0001 0111 (binary) = ? (hex) = ? (octal) 3F9(hex) = ? (binary) = ? (octal) 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Some tricks Multiplication by a constant of power of 2 Shifting the number left by some bits The number of bits should be ? 2 x 2 = 4 010 0100 2 x 4 = 8 010 ? 3 x 8 = ?? 011 ? Much faster to implement a shift instruction(1 clock cycle) than multiple instruction (32 clock cycles) What about divisions ? 4 / 2 = ? Even or Odd numbers ? An Example 0 1 2 3 2 0 2 1 2 0 2 1 2 8 10 × + × + × + × = + = 0 1 2 2 1 2 0 2 1 5 2 / × + × + × = = 0 1 2 0 2 1 2 2 / 5 × + × = = 0 2 1 1 2 / 2 × = =
Background image of page 6
7 Decimal  Binary Decimal Binary By successive halving, starting at the top and working downward, record the quotient and the remainder. 1492/2=746. .0 746/2=373. .0 373/2=186. .1 186/2= 93. .0 . . 1 /2= 0. .1 Record the reminders from right (LSD) to left (MSD)
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Exercise Convert 96 from decimal to binary Convert 37 to binary, shift it left by one and convert back to decimal. What is the result?
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/27/2011 for the course CMPSC 64 taught by Professor Zheng during the Fall '09 term at UCSB.

Page1 / 24

lecture2 - CS 64 Lecture 2 Data Representation Reading: FLD...

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

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