Loose Leaf For Introduction To Computing Systems: From Bits & Gates To C & Beyond
Loose Leaf For Introduction To Computing Systems: From Bits & Gates To C & Beyond
3rd Edition
ISBN: 9781260424744
Author: Yale N. Patt, Sanjay Patel
Publisher: McGraw-Hill Education
Question
Book Icon
Chapter 2, Problem 11E

a.

Program Plan Intro

Steps to convert decimal to binary:

  • Form the following equation to represent the decimal value “N” in binary representation,

N=26×b6+25×b5+24×b4+23×b3+22×b2+21×b1+20×b0

  • Repeat the following steps till the left side of the equation becomes “0”.
    • If the value of “N” is even, then the rightmost digit is “0”, and otherwise it is “1”.
    • Minus “1” or “0” from the value of “N”, neglect least significant term from the right side of the equation.
    • Divide left and right sides of the equation by “2”. Each repetition gives the value of one coefficient “bj
  • Extend the sign bit by adding 0’s to the left, if the original decimal value is positive.
  • Extend the sign bit by adding 0’s to the left and make the complement of this 2’s complement representation, if the original decimal value is negative.

b.

Explanation of Solution

Conversion of decimal number “64” to binary number:

  • Form the following equation to represent the decimal value “64” in binary representation,

64=26×b6+25×b5+24×b4+23×b3+22×b2+21×b1+20×b0

  • The given value is positive hence, the Left most Significant Bit (LSB) “b7” in eight-bit representation is “0”.
  • If the value “64” is even, then the rightmost digit is “0”.
  • The given value is even hence, the rightmost digit “b0” is “0”.
  • Subtract the value “0” from the both sides of the equation as follows,

64=26×b6+25×b5+24×b4+23×b3+22×b2+21×b1

  • Divide left and right sides of the equation by “2”. The equation will become as follows,

32=25×b6+24×b5+23×b4+22×b3+21×b2+20×b1

  • The value “32” is even hence, the rightmost digit “b1” is “0”.
  • Subtract the value “0” from the both sides of the equation as follows,

32=25×b6+24×b5+23×b4+22×b3+21×b2

  • Divide left and right sides of the equation by “2”. The equation will become as follows,

16=24×b6+23×b5+22×b4+21×b3+20×b2

  • The value “16” is even hence, the rightmost digit “b2” is “0”

c.

Explanation of Solution

Conversion of decimal number “33” to binary number:

  • Form the following equation to represent the decimal value “33” in binary representation,

33=26×b6+25×b5+24×b4+23×b3+22×b2+21×b1+20×b0

  • The given value is positive hence, the Left most Significant Bit (LSB) “b7” in eight-bit representation is “0”.
  • If the value “33” is odd, then the rightmost digit is “1”.
  • The given value is odd hence, the rightmost digit “b0” is “1”.
  • Subtract the value “1” from the both sides of the equation as follows,

32=26×b6+25×b5+24×b4+23×b3+22×b2+21×b1

  • Divide left and right sides of the equation by “2”. The equation will become as follows,

16=25×b6+24×b5+23×b4+22×b3+21×b2+20×b1

  • The value “16” is even hence, the rightmost digit “b1” is “0”.
  • Subtract the value “0” from the both sides of the equation as follows,

16=25×b6+24×b5+23×b4+22×b3+21×b2

  • Divide left and right sides of the equation by “2”. The equation will become as follows,

8=24×b6+23×b5+22×b4+21×b3+20×b2

  • The value “8” is even hence, the rightmost digit “b2” is “0”

d.

Explanation of Solution

Conversion of decimal number “-128” to binary number:

  • Form the following equation to represent the decimal value “128” in binary representation,

128=26×b6+25×b5+24×b4+23×b3+22×b2+21×b1+20×b0

  • The given value is negative hence, the Left most Significant Bit (LSB) “b7” in eight-bit representation is “1”.
  • If the value “128” is even, then the rightmost digit is “0”.
  • The given value is even hence, the rightmost digit “b0” is “0”.
  • Subtract the value “0” from the both sides of the equation as follows,

128=26×b6+25×b5+24×b4+23×b3+22×b2+21×b1

  • Divide left and right sides of the equation by “2”. The equation will become as follows,

64=25×b6+24×b5+23×b4+22×b3+21×b2+20×b1

  • The value “64” is even hence, the rightmost digit “b1” is “0”.
  • Subtract the value “0” from the both sides of the equation as follows,

64=25×b6+24×b5+23×b4+22×b3+21×b2

  • Divide left and right sides of the equation by “2”. The equation will become as follows,

32=24×b6+23×b5+22×b4+21×b3+20×b2

  • The value “32” is even hence, the rightmost digit “b2” is “0”

e.

Explanation of Solution

Conversion of decimal number “127” to binary number:

  • Form the following equation to represent the decimal value “127” in binary representation,

127=26×b6+25×b5+24×b4+23×b3+22×b2+21×b1+20×b0

  • The given value is positive hence, the Left most Significant Bit (LSB) “b7” in eight-bit representation is “0”.
  • If the value “127” is odd, then the rightmost digit is “1”.
  • The given value is odd hence, the rightmost digit “b0” is “1”.
  • Subtract the value “1” from the both sides of the equation as follows,

126=26×b6+25×b5+24×b4+23×b3+22×b2+21×b1

  • Divide left and right sides of the equation by “2”. The equation will become as follows,

63=25×b6+24×b5+23×b4+22×b3+21×b2+20×b1

  • The value “63” is odd hence, the rightmost digit “b1” is “1”.
  • Subtract the value “1” from the both sides of the equation as follows,

62=25×b6+24×b5+23×b4+22×b3+21×b2

  • Divide left and right sides of the equation by “2”. The equation will become as follows,

31=24×b6+23×b5+22×b4+21×b3+20×b2

  • The value “31” is odd hence, the rightmost digit “b2” is “1”

Blurred answer
Students have asked these similar questions
2. Consider the following pseudocode for partition: function partition (A,L,R) pivotkey = A [R] t = L for i L to R-1 inclusive: if A[i] A[i] t = t + 1 end if end for A [t] A[R] return t end function Suppose we call partition (A,0,5) on A=[10,1,9,2,8,5]. Show the state of the list at the indicated instances. Initial A After i=0 ends After 1 ends After i 2 ends After i = 3 ends After i = 4 ends After final swap 10 19 285 [12 pts]
.NET Interactive Solving Sudoku using Grover's Algorithm We will now solve a simple problem using Grover's algorithm, for which we do not necessarily know the solution beforehand. Our problem is a 2x2 binary sudoku, which in our case has two simple rules: •No column may contain the same value twice •No row may contain the same value twice If we assign each square in our sudoku to a variable like so: 1 V V₁ V3 V2 we want our circuit to output a solution to this sudoku. Note that, while this approach of using Grover's algorithm to solve this problem is not practical (you can probably find the solution in your head!), the purpose of this example is to demonstrate the conversion of classical decision problems into oracles for Grover's algorithm. Turning the Problem into a Circuit We want to create an oracle that will help us solve this problem, and we will start by creating a circuit that identifies a correct solution, we simply need to create a classical function on a quantum circuit that…
using r language
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education