Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part I: Extracting Bits (10 points) Write a function extract_bits_3_9 (), which

ID: 3716376 • Letter: P

Question

Part I: Extracting Bits (10 points) Write a function extract_bits_3_9 (), which takes a single integer argument named num. The function extracts bits 3 through 9, returning them as an integer. Remember that the rightmost bit is bit #0 As an example, suppose num is 1,521,342. In binary, this value is Let's highlight bits 3 through 9, inclusive: The function needs to perform various masking and/or shifting operations as needed so that the function will return 1010111 The above number written in decimal is 87, which is what the function would ultimately return. CSE 101 - Spring 2018 Lab #12 Page 1 Remember that all data in a computer is stored in binary format, so it is not necessary for you to tell the computer to explicitly convert between base 10 and base 2. All integers are represented in binary, but will be printed iin decimal to the screen You might find a base conversion website helpful while completing this assignment. Many such websites can be found with a quick Google search Examples: The function arguments in the examples below are expressed in binary (denoted by the leading Ob), making it easier to understand the returned result Function Call extractbits.3_9 (0b11100110001001101010010000) Return Value 0b1010010 extractbits_3_9 (0b101100101001110100011010) extractbits_3_9 (0b10010100111101) extract.bits 3_9 (0b11011000001) extract bits.39 (0b100110010 0000 0b1111 0b100011 0b100111 0b1011000 Qh1100100

Explanation / Answer

OUTPUT:

0b100000000 = 32

#The first one is binary representation of number 256, and it will return 32.