Unformatted text preview:

Chapter 3 Number Systems Common number systems Decimal Binary Octal Hexidecimal General number system Base n Real numbers non integers Binary Fractions In the Beginning Applies to Chapter 4 as well In the beginning people represented numbers with is seven We use 7 5 12 1 10 1 2 0 base ten because we have ten fingers BIG CONCEPT ignored in life but important for computers Number representation vs Number There are many ways to represent a number e g above Representation does not affect the result of an operation XII XXXIII XLV 12 33 45 But representation affects difficulty of computing result XXXIII 33 XII 12 XXXIII XXXIII CCCXXX CCCXXXXXXXXXIIIIII CCCLXXXXVI CCCXCVI 396 For computer we need to chose a representations that allows us to build fast electronic circuits for computer e g adding Since computer don t have fingers they don t use base ten number Summary We will review number systems The next chapter applies the ideas to computers Representing positive integers 1 2 3 Big advance of humankind Arabic numerals weighted position notation with base ten 345 is really 3 x 100 4 x 10 5 x 1 3 x 10 2 4 x 10 1 5 x 10 0 3 is the most significant symbol it carries the most weight 5 is the least significant symbol it carries the least weight digits or symbols allowed 0 9 base or radix 10 Pronunciation rA diks For computer binary number work great why two state devices Binary number system base radix digits allowed 2 0 1 each binary digit is called a BIT the order of the digits is significant numbering of the digits msb lsb n 1 0 where n is the number of digits in the number msb stands for most significant bit lsb stands for least significant bit 1001 base 2 is really 1 x 2 3 0 x 2 2 9 base 10 0 x 2 1 11000 base 2 is really 1 x 2 4 1 x 2 3 0 x 2 2 0 x 2 1 24 base 10 system roman Arabic binary 20th C e g humans XVIII bad 18 good 100010 bad 1 x 2 0 0 x 2 0 computers bad bad good Humans might multiply Romans numerals by converting to Arabic multiplying and converting back Computer usually multiply Arabic numerals by converting to binary multiplying and converting back Decimal number system example The Base determines how many different symbols are needed to represent values in that base We use the decimal digits we learned as children to represent the first ten symbols of any base The order of the digits is significant For example 345 does not represent the same value as 534 base radix digits allowed 9 base 10 9 10 0 324 base 10 3 x 10 2 2 x 10 1 4 x 10 0 10 0 1 2 3 4 5 6 7 8 9 Humans use octal or hex to read binary number we ll see why when we learn how to convert bases Octal number system 8 0 1 2 3 4 5 6 7 base radix digits allowed Examples 345 base 8 is really 3 x 8 2 192 4 x 8 1 5 x 8 0 32 5 229 base 10 1001 base 8 is really 1 x 8 3 512 0 x 8 2 0 x 8 1 1 x 8 0 513 base 10 0 0 1 Hexidecimal number system hex 0 1 9 a b c d e f decimal 0 1 9 10 11 12 13 14 15 Why a f Need six more symbols Could use heart club diamond spade square and triangle But a f are on keyboard and it s easy to remember c is one bigger then b Note English has a special symbol for twelve not ten ee two like twenty three 16 base radix 0 1 2 3 4 5 6 7 8 9 a b c d e f digits allowed a3 base 16 is really example a3 a 16 1 3 16 0 a 16 3 1 10 16 3 160 3 163 base 10 3e8 base 16 is really 3 x 16 2 e x 16 1 8 x 16 0 3 x 256 14 x 16 8 x 1 768 224 8 1000 base 100 base 16 1 x 16 2 1 x 256 256 10 is really 0 x 16 1 0 x 16 0 0 x 16 0 0 x 1 0 256 base 10 Common MIPS syntax for hexidecimal numbers is 0x preceding the digits0x1234 is 1234 Base 16 Intel uses an h as a suffix of hexidecimal numerals General number system Base B numbers Any number can be used as a base for a number system If the number is less than or equal to 10 we can use a subset of the digits 0 9 for the symbols if the base is greater than 10 we use letters as additional symbols so that each digit takes up only one place in the numeral o Example Hexadecimal In each of these number systems the position of the symbols digits is important to the actual value of the numeral Since we are more familiar with decimal values we frequently wish to know the decimal value of a number that was given in a different base How do I convert a number from a different base to decimal Calculate the decimal value of each weighted symbol digit in the numeral and sum each of these values Ok but then how do I calculate the decimal value of a single digit in the numeral Use the digit s position in the numeral shown as a subscript as the power or the exponent of the base and multiply that term with the digit Decimal value of the nth bit digit S in a Base B numeral Sn Bn Let s put the solution all together now for a Base B numeral of the form Sn 1 Sn 2 n is the B is the S is the in the numeral S2 S1 S0 number of bits in the numeral base of the numeral symbol digit at that location Decimal value of a Base B numeral Sum i 0 Example abcBase B to n 1 Base Si Bi 10 GENERAL EQUATION abcBase B a B2 b B1 c B0 aB2 bB c Base 10 Base 10 decimal binary Two ways 1 divide decimal value by 2 until the value is 0 see book 2 know your powers of two and subtract Method 2 256 d 128 64 d d d 32 16 8 4 2 d d d d d 1 E g 42 What is the biggest power of two that fits 32 42 32 10 What fits 8 10 8 2 What fits 2 2 2 0 done one 32 one 8 one 2 one 32 zero 16 one 8 zero 4 one 2 zero 1 1 0 1 0 1 0 101010 Some other common base transformations Any base decimal base 10 decimal binary base 2 Use the summation equation as given above …


View Full Document

UW-Madison CS 354 - Chapter 3 - Number Systems

Loading Unlocking...
Login

Join to view Chapter 3 - Number Systems 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 Chapter 3 - Number Systems 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?