;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "2017-fall-reader.rkt" "csc104")((modname Week-12-Lab) (compthink-settings #hash((prefix-types? . #f))))
; Exercises for Week 12
; =====================
; The quiz on December 6th will be related to this exercise.
; You should do very well on the quiz if you try out everything below.
; Instructors/TAs are available before quizzes for questions, 10--3 on Wednesday in BA 3175.
; Quiz Rooms
; ----------
; TUT0201 11-12
; 11:30 surnames A--L RS310
; 11:30 surnames M--V HA316
; 11:45 surnames W--Z RS310
;
; TUT0301 12--1
; 12:30 surnames A--M BF323
; 12:45 surnames N--Z BF323
;
; TUT0401 1--2
; 1:30 surnames A--M UC256
; 1:45 surnames N--Z UC256
;
; TUT0501 2--3
; 2:30 surnames A--M RS310
; 2:45 surnames N--Z RS310
;
; TUT0101 3--4
; 3:30 surnames A--M RW140
; 3:45 surnames N--Z RW140
; From Test 2 Winter 2017 - Question 3
;
; Convert the binary representation 1001101 to its decimal representation,
; briefly showing your steps.
; From Test 2 Winter 2016 - Question 1
; Part (a)
; Convert 77 to its binary representation, briefly showing your steps
; Part (b)
; Convert the binary representation 1011010 to its decimal representation,
; briefly showing your steps.
; Part (c)
; Add the numbers whose binary representations are 1110110 and 1010100
; (without converting them to decimal notation). Show your work (i.e. when you "carry" a 1).
; From Test 2 Fall 2015 - Question 2
; Part (a)
; Convert 44 to its binary representation, BRIEFLY showing the steps of your procedure.
; Part (b)
; Convert the binary representation 1010011 to its decimal representation,
; BRIEFLY showing the steps of your procedure.
; From Test 2 Winter 2015 - Question 1
; Part (a)
; Convert 54 to its binary representation, BRIEFLY showing the steps of your procedure.
; Part (b)
; Convert the binary representation 1010011 to its decimal representation, BRIEFLY showing
; the steps of your procedure.
; Part (c)
; Add the numbers whose binary representations are 11010 and 11011 (without converting them
; to decimal notation). Show your work (i.e. when you "carry" a 1).
; Want more practice?
; Use this statement to get more decimal numbers to convert to binary.
; You can increase 100 to a larger number to try bigger numbers.
#; (random 100)
; Use these statements to get more binary numbers to convert to decimal,
; or to get more binary numbers to practice adding.
; You can increase 100 to a larger number to try bigger numbers.
#;(define (number->bits n)
(cond [(equal? 0 n) (list)]
[(even? n) (append (number->bits (/ n 2)) (list 0))]
[else (append (number->bits (/ (- n 1) 2)) (list 1))]))
#;(number->bits (random 100))