CSE 20 DISCRETE MATH Prof Shachar Lovett http
- Slides: 21
CSE 20 DISCRETE MATH Prof. Shachar Lovett http: //cseweb. ucsd. edu/classes/wi 15/cse 20 -a/ Clicker frequency: CA
Todays topics • Algorithms: number systems, binary representation • Section 1. 3 in Jenkyns, Stephenson
Numbers are building blocks Five
Positional representation JS p. 22 What’s the (decimal) value of 10001 {2}? A. 5 {10} B. 17 {10} C. -1 {10} D. 10001 {10} E. None of the above / more than one of the above.
Positional representation JS p. 22 What’s the base 2 representation of the (decimal) number 42 {10}? A. 111111 {2} B. 100001 {2} C. 101010 {2} D. 110011 {2} E. None of the above / more than one of the above.
Positional representation JS p. 22 What’s the biggest integer value whose binary representation has 4 bits? A. 24 = 16 {10} B. 23 = 8 {10} C. 4 {10} D. 1000 {10} E. None of the above / more than one of the above.
Uniqueness Is it possible to have ? A. No. B. Yes, but m has to be the same as n. C. Yes, and m, n can be different but for each kind of coefficient that appears in both, it has to agree. That is, a 0 = b 0, a 1 = b 1, etc. D. Yes, if m=n and all the coefficients agree. E. More than one of the above / none of the above.
Parity and shift
Shifts
Positional representation JS p. 22 What’s the base 2 representation of the (decimal) number 2014 {10}? A. 111110 {2} B. 100000 {2} C. 1010101 {2} D. 100001 {2} E. None of the above / more than one of the above.
Positional representation JS p. 22 What’s the base 2 representation of the (decimal) number 2014 {10}? A. 111110 {2} B. 100000 {2} C. 1010101 {2} D. 100001 {2} E. None of the above / more than one of the above. Is there a systematic way (aka algorithm) to do it?
Decimal to Binary conversion • Right to left • Questions to ask: • Does it always terminate? • Does it give the correct answer? • What is the time complexity? to. Binary(pos int n) Begin x “”; i n; While i>0 Do If (i is even) Then x “ 0”. x; End; If (i is odd) Then x “ 1”. x; End; i i/2; Output x End.
Other numbers? • Fractional components • Negative numbers aka how to subtract … first, how do we add? A. 111 C. 1011 B. 100 D. 1111 E. None of the above.
One bit addition Carry: 1 101 +110 1001
Subtraction • Borrowing A – B = (A – 10) + (10 – B) • Carrying A – B = (A+10) – (B+10) • Complementation A – B = A + Bc = A + [ (99 -B) - 99 ] = A + [ (100 -B) – 100 ] JS p. 6
2’s complement 0000 1111 1110 1101 1100 Complete the wheel of numbers! -2 -1 0 0001 0010 1 2 -3 3 4 5 -4 -5 -6 -7 -8 1001 1000 How many numbers are we representing with 4 bits? 7 6 0111 0011
How to add binary numbers? 110010101 +101101101 ? ? ? ? ?
How to add binary numbers? ? ? ? ? 110010101 +101101101 ? ? ? ? ? (carry)
How to add binary numbers? ? ? ? ? 110010101 +101101101 ? ? ? ? ? • Two basic operations: • One-Bit-Addition(bit 1, bit 2, carry) • Next-carry(bit 1, bit 2, carry) (carry)
Numbers … logic … circuits
Next class • Boolean circuits and truth tables • Read sections 3. 2 -3. 4 in Jenkyns, Stephenson
- Shachar lovett
- Shachar tauber
- Mmt grades 0-5
- Jade lovett
- Lovett
- Marsha lovett
- What is discrete mathematics
- Inverse error fallacy
- Modeling computation discrete math
- Absorption law
- Discrete mathematics question
- Discrete math propositional logic
- Sequences in discrete mathematics
- Matrix representation of composite relation
- Set identites
- Floor and ceiling discrete math
- Four parts of mathematical system
- What does onto mean in discrete math
- Subtraction rule discrete math
- What is discrete math
- Nested quantifiers
- Discrete math susanna epp