DOC PREVIEW
UCSC CMPE 012 - Integer Numbers

This preview shows page 1-2-17-18-19-35-36 out of 36 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CMPE12 – Spring 2008 – Andrea Di BlasThe Number Bases of IntegersTextbook Chapter 3CMPE12 – Summer 2008Integer NumbersCMPE12 – Summer 2008 – Slides by ADB 2Number Systems Unary, or marks: /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better: Arabic Numerals: 7 + 5 = 12 = 1·10 + 22CMPE12 – Summer 2008 – Slides by ADB 3 The value represented by a digit depends on its positionin the number. Ex: 1832Positional Number SystemCMPE12 – Summer 2008 – Slides by ADB 4Number = (di·bp)i=0∑num digitsPositional Number Systems Select a number as the base b Define an alphabet of b–1 symbols plus a symbol for zero to represent all numbers Use an ordered sequence of 2 or more digits dto represent numbers The represented number is the sum of all digits, each multiplied by b to the power of the digit’s position p3CMPE12 – Summer 2008 – Slides by ADB 5 First used over 4000 years ago in Mesopotamia Base 60 (Sexagesimal), alphabet: 0..59, written as 60 different symbols But the Babylonians used only two symbols, 1 and 10, and didn’t have the zero Needed context to tell 1 from 60! Example 5,4560=Sexagesimal: A Positional Number SystemCMPE12 – Summer 2008 – Slides by ADB 6Babylonian Numbers4CMPE12 – Summer 2008 – Slides by ADB 7Arabic/Indic Numerals Base 10 (decimal) The alphabet is 0..9 We use the Arabic symbols for the 10 digits Has the ZERO Numerals introduced to Europe by Leonardo Fibonacci in his Liber Abaci In in 1202 So useful!CMPE12 – Summer 2008 – Slides by ADB 8Arabic/Indic Numerals The Italian mathematician Leonardo Fibonacci Also known for the Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 215CMPE12 – Summer 2008 – Slides by ADB 9Base ConversionThree cases:I. From any base b to base 10II. From base 10 to any base bIII. From any base b to any other base cCMPE12 – Summer 2008 – Slides by ADB 10From Base b to Base 10Value = Σ (dibi)n-1i=0Value = Σ (dibi)n-1i=0 Positional number systems make it easy6CMPE12 – Summer 2008 – Slides by ADB 11From Base b to Base 10 Example: 12345 = ?10CMPE12 – Summer 2008 – Slides by ADB 12From Base 10 to Base b Use successive divisions Remember the remainders Divide again with the quotients7CMPE12 – Summer 2008 – Slides by ADB 13From Base 10 to Base b Example: 200810 = ?5CMPE12 – Summer 2008 – Slides by ADB 14From Base b to Base c Use a known intermediate base The easiest way is to convert from base b to base 10 first, and then from 10 to c  Or, in some cases, it is easier to use base 2 as the intermediate base (we’ll see them soon)8CMPE12 – Summer 2008 – Slides by ADB 15Number of Digits How many digits are required to represent a number x in base b?CMPE12 – Summer 2008 – Slides by ADB 16Roman MultiplicationXXXIII (33 in decimal)XII (12 in decimal)--------------9CMPE12 – Summer 2008 – Slides by ADB 17Positional Multiplication1135425---------------------------(a lot easier!)CMPE12 – Summer 2008 – Slides by ADB 18Numbers for Computers There are many ways to represent a number Representation does not affect computation result Representation affects difficulty of computing results Computers need a representation that works with (fast) electronic circuits Positional numbers work great with 2-state devices Which base should we use for computers?10CMPE12 – Summer 2008 – Slides by ADB 19Binary Number System Base (radix): 2 Alphabet: 0, 1 Binary Digits, or bits Example:  10012=  110002=CMPE12 – Summer 2008 – Slides by ADB 20Octal Number System Base (radix): 8 Alphabet: 0, 1, 2, 3, 4, 5, 6, 7 3458=  10018=  In C, octal numbers are represented with a leading 0.11CMPE12 – Summer 2008 – Slides by ADB 21Hexadecimal Number System Base (radix): 16 Alphabet: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F In C: leading “0x” (e.g., 0xa3) In LC-3: leading “x” (e.g., “x3000”) Hexadecimal is also known as “hex” for short15f14e13d12c11b10aDecimalHexCMPE12 – Summer 2008 – Slides by ADB 22Examples of Converting Hex to Decimal A316=  3E816=12CMPE12 – Summer 2008 – Slides by ADB 23Decimal To Binary ConversionMethod 1 Divide decimal value by 2 until the value is 0 Example: 44410 Divide 444 by 2; what is the remainder? Divide 222 by 2; what is the remainder? … Result is 0: done Read backwards for binary representationCMPE12 – Summer 2008 – Slides by ADB 24Decimal To Binary ConversionMethod 2 Know your powers of two and subtract Example: 6110 What is the biggest power of two that fits? What is the remainder? What fits? What is the remainder? … What is the binary representation?13CMPE12 – Summer 2008 – Slides by ADB 25Knowing The Powers Of Two Know them in your sleep29210282726252423222120CMPE12 – Summer 2008 – Slides by ADB 26Binary to Octal Conversion Group into 3 starting at least significant bit Why 3? Add leading 0 as needed  Why not trailing 0s? Write one octal digit for each group14CMPE12 – Summer 2008 – Slides by ADB 27Binary to Octal Conversion: Examples 100 010 111 (binary) ___________ (octal) 10 101 110 (binary) ___________ (octal)CMPE12 – Summer 2008 – Slides by ADB 28Binary to Hex Conversion Group into 4 starting at least significant bit Why 4? Add leading 0 if needed Write one hex digit for each group15CMPE12 – Summer 2008 – Slides by ADB 29Binary to Hex Conversion: Examples 1001 1110 0111 0000 (binary) ___________________ (hex) 0001 1111 1010 0011 (binary) ___________________ (hex)CMPE12 – Summer 2008 – Slides by ADB 30Octal to Binary Conversion Write down the 3-bit binary code for each octal digit Example: 04711171106101510040113010200110000BinaryOctal16CMPE12 – Summer 2008 – Slides by ADB 31Hex to Binary Conversion Write down the 4-bit binary code for each hex digit Example: 0x 3 9 c 81111f011171110e011061101d010151100c010041011b001131010a0010210019000111000800000BinHexBinHexCMPE12 – Summer 2008 – Slides by ADB 32Conversion Table111117F15111016E14110115D13110014C12101113B11101012A10100111991000108801117770110666010155501004440011333001022200011110000000BinaryOctalHexadecimalDecimal17CMPE12 – Summer 2008 – Slides by ADB 33More Conversions


View Full Document

UCSC CMPE 012 - Integer Numbers

Download Integer Numbers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Integer Numbers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Integer Numbers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?