Week 1 Notes
Popular in Computer Science
Popular in Department
This 5 page Class Notes was uploaded by Heather Perkins on Friday January 23, 2015. The Class Notes belongs to 13803 at University of Massachusetts taught by William Verts in Spring2015. Since its upload, it has received 91 views.
Reviews for Week 1 Notes
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 01/23/15
CompSci 105 Numbers and the Computer 01222015 BIT Binary Digit 0 Fundamental unit of information Has two values 0 and 1 o The 0 amp 1 values represent a single yes or no question 0 Can also encode any two valued system 0 Yesno truefalse updown etc Easy to build hardware to encode bits 1 bit gives 21 2 patterns 0 amp 1 2 bits gives 22 4 patterns 00011011 3 bits gives 23 8 patterns 000001010011100101110111 Each new bit doubles the number of patterns therefore N Bits gives 2Ndistinct patterns Byte packet of 8 bits French word is quotoctetquot Typical unit of computer memorystorage Values range from 0000000111111 o Gives us 28 or 256 distinct patterns 0 Can encode any integer between 0 and 255 0 Value that s all 0 bits is 0 and value that s all 1 bits is 255 Unsigned Integers Pick storage size of N bits 8163264 etc o Newer machines can deal with more bits at a time o The bigger N is the more numbers you can represent and push around at one time Therefore 2N distinct patterns are available Smallest value is all zeros decimal value 0 Largest value is therefore 2N1 Results less than zero are quotunder owquot errors 0 Results greater than max are over ow errors 0 Each computer architecture has a xed N Signed Integers 0 Pick N there are still 2N patterns 0 Consider half the patterns to be negative 0 Half of 2N 2N 2 2N 391 Remaining patterns are zero and above 0 Once you pick N the range of values you can represent is therefore 2N 12 N3911 0 Zero is considered positive Example for N8 o 28256 patterns or 1 byte 0 Unsigned range minimum 0 maximum 281 255 o Signed range minimum 28 391 2 7 128 Maxiumum 2 83911 2 71128 1127 When using signed unsigned integers there are no fractions so you can t do computations involving fractions Real Numbers Approaches o Rational ratio of integers For N bits divide into two n2 bit sections a First section is the numerator a Second section is the denominator Since you reduce fractions to the lowest form there are many redundant patterns there is a low information density and it s not an ef cient use of bits 0 Fixed point Set virtual decimal point to the middle of bits a Half the bits are integer a Half the bits are fractions All bit patterns are useful Easy to add subtract multiply divide in binary Trades off range of values for fraction support a For N16 max signed value is only 12799609375 It s still not an efficient use of bits 0 Floatind point Binary version of Scienti c Notation n Decimal 34024x10quot15 n Binary 100101001x2quot1001 Use one bit for sign Oplus 1minus Use some of the N bits for exponent Use remaining bits for mantissa signi cand Trades off precision for dynamic range a You don t get as many signi cant digits but you get a lot of power in where you put the decimal point Singe Precision n N32 Bits 1 sign 8 exponent 23 mantissa a Dynamic range10 38 a Signi cant gures 56 decimal digits I Remember 32 bit integers have about 9 sig gs Double precision used by excel n N64 bits 1 sign 11 exponent 52 mantissa a Dynamic range 10 308 a Signi cant gures 1516 decimal digits 0 All require reinterpreting how bits are used Long fractions get rounded off 0 Expected loss of precision o Naturally long but nite fractions 0 Rationals that repeat forever 13 0 lrrationals e pi etc Unexpected loss of precision wellbehaved decimal fractions that are illbehaved in binary 110 Proof that V2 is irrational Remember evenxeveneven evenxodd even oddxoddodd Assume 2 is rational 2 PQ 0 Assume lowest form p q aren t both even o If both were even we can repeatedly divide both p and q by 2 until at least one is odd 0 1 Square both sides 2p2q2 2 Multiply by 02 202 P 2 0 CONCLUSION 1 P2 is even thus P is even 0 3 Divide by 2 OZ P22 px P2 CONCLUSION 2 Q 2is even thus Q is even Contradiction initial assertion was P Q aren t both even proof says both are even thus assumption that 2 PQ is false No such rational number exists Biggest secret of computing 0 Most of the interesting numbers in the universe are irrational Numbers on computers have a xed and nite number of bits Therefore most values get rounded off Most numerical results are approximations More bits means more precision but only forestalls and does not eliminate the problem Complex Numbers The Real number line extends from oo to 00 Use of space above and below the line gives us more computational expressive power Negation then becomes a rotation of 180 Mapping multiplication onto rotation Multiplying a number by l twice equals negation thus iquot2 01 and Complex number is a pair of numbers 0 A value along the real axis 0 A value along the imaginary axis Written with the real part rst then imaginary 23I
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'