1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
masya89 [10]
2 years ago
8

Find the word-length 2's complement representation of each of the following decimal numbers:a. 845b. 15000c. 100d. -923

Computers and Technology
2 answers:
Norma-Jean [14]2 years ago
8 0

Answer:

Using 32bits.

a:0000 0000 0000 0000 0000 0011 0100 1101

b:0000 0000 0000 0000 0011 1010 1001 1000

c:0000 0000 0000 0000 0000 0000 0110 0100

d:1111 1111 1111 1111 1111 1100 0110 0101

Explanation:

Conversion to Two's Complement

The 2's complement system is commonly used for signed integer representation on computers.  The 2's complement operation is done by inverting the binary digits of an integer and then adding one.

For the purpose of explanation lets make use of a negative number for clarity. In this case lets use -923.

Note that the use of 32bits for this question is objective, you can use a range of bits for this operation. this question can go as low as 16bits and as high as 64bits depending on application and specification.

For Example:

we have -923, and want to represent it in 2's complement, you take the binary representation of positive 923:

0000 0000 0000 0000 0000 0011 1001 1011

Invert the digits.

1111 1111 1111 1111 1111 1100 0110 0100

And add one.

1111 1111 1111 1111 1111 1100 0110 0100 + 1

=

1111 1111 1111 1111 1111 1100 0110 0101

(The Binary 2's complement representation of -923)

tino4ka555 [31]2 years ago
3 0

Answer:

(a) 845 = 0000 0011 0100 1101

(b) 1500 = 0011 1010 1001 1000

(c) 100 = 0000 0000 0110 0100

(d) -923 = 1111 1100 0110 0101

Explanation:

<u>NOTES:</u>

<em>First Note: The question requests that the numbers be represented in word-length. That means they should be represented in 16bits (a word is 2 bytes).</em>

<em>Second Note: To convert a number to its 2's complement representation,</em>

<em>(i) if the number is positive, the usual conversion to binary will suffice. You might just need to add zero at the beginning of the sequence of bits to ensure that the leftmost bit is a zero(0).</em>

<em>(ii) if the number is negative, then;</em>

<em>=> convert the magnitude of the number to its binary</em>

<em>=> add zeros to the beginning of the sequence of binary until the sequence has the specified length</em>

<em>=> flip each bit in the sequence and add 1 to the result.</em>

<u>SOLUTION:</u>

Applying the rules in the notes above, lets convert the numbers.

(a) 845 => The number is positive, conversion to its binary will suffice

<u>2  |  845</u>

<u>2  |  422 R 1</u>

<u>2  |  211 R 0</u>

<u>2  |  105 R 1</u>

<u>2  |  52 R 1</u>

<u>2  |  26 R 0</u>

<u>2  |  13 R 0</u>

<u>2  |  6 R 1</u>

<u>2  |  3 R 0</u>

<u>2  |  1 R 1</u>

<u>2  |  0 R 1</u>

Writing the remainders upwards, we have

845 = 1101001101

Pad with zeros to convert it to its word-length representation.

845 = 0000 0011 0100 1101

(b) 15000 => The number is also positive, so following the same step as above,

15000 = 11101010011000

Pad with zeros to convert it to its word-length representation.

15000 = 0011 1010 1001 1000

(c) 100 => The number is also positive, so following the same step as above,

100 = 1100100

Pad with zeros to convert it to its word-length representation.

100 =  0000 0000 0110 0100

(d) -923 => The number is negative;

-->  first convert its magnitude (923) to binary

923 = 1110011011

--> Pad with zeros to convert it to its word-length representation.

923 =  0000 0011 1001 1011

--> Flip the bits

0000 0011 1001 1011 = 1111 1100 0110 0100

--> Add 1 to the result above

1111 1100 0110 0100 + 1 = 1111 1100 0110 0101

Therefore;

-923 = 1111 1100 0110 0101

You might be interested in
PLEASE HELP
kramer
Style  would be the great and best answer but you could add office decor
7 0
3 years ago
Read 2 more answers
g Write a program that prompts the user for an integer n between 1 and 100. If the number is outside the range, it prints an err
grin007 [14]

Answer:

The cpp program is given below.

#include<iostream>

#include<iomanip>

using namespace std;

int main() {

   

   // variables declared

   int n;

   int sum=0;

   float avg;

   

   do

   {

       // user input taken for number    

       cout<< "Enter a number between 1 and 100 (inclusive): ";

       cin>>n;

       

       if(n<1 || n>100)

           cout<<" Number is out of range. Enter valid number."<<endl;

       

   }while(n<1 || n>100);

   

   cout<<" "<<endl;

   

   // printing even numbers between num and 50  

   for(int num=1; num<=n; num++)

   {

       sum = sum + num;

   }

   

   avg = sum/n;

   

   // displaying sum and average

   cout<<"Sum of numbers between 1 and "<<n<<" is "<<sum<<endl;

   cout<<"Average of numbers between 1 and "<<n<<" is ";

   printf("%.2f", avg);

   

       return 0;

}

OUTPUT

Enter a number between 1 and 100 (inclusive): 123

Number is out of range. Enter valid number.

Enter a number between 1 and 100 (inclusive): 56

 

Sum of numbers between 1 and 56 is 1596

Average of numbers between 1 and 56 is 28.00

Explanation:

The program is explained below.

1. Two integer variables are declared to hold the number, n, and to hold the sum of numbers from 1 to n, sum. The variable sum is initialized to 0.

2. One float variable, avg, is declared to hold average of numbers from 1 to n.

3. User input is taken for n inside do-while loop. The loop executes till user enters value between 1 and 100. Otherwise, error message is printed.

4. The for loop executes over variable num, which runs from 1 to user-entered value of n.

5. Inside for loop, all the values of num are added to sum.

sum = sum + num;

6. Outside for loop, average is computed and stored in avg.

avg = sum/n;

7. The average is printed with two numbers after decimal using the following code.

printf("%.2f", avg);

8. The program ends with return statement.

9. All the code is written inside main() and no classes are involved.

3 0
3 years ago
Technology can most broadly be defined as anything that does which of the following ?
Anastasy [175]
I would say A. Allowing us to improve efficiency in the workplace has helped grow our economy and we can thank technology for that. Due the it always improving our lives only get that much easier.
5 0
3 years ago
Computers can accomplish many tasks today, but there are still some things they cannot do. Think of some of the things you would
postnew [5]
Record our dream.
Since it is from the future and advanced, it is invalid to argue back that the wish to record our dreams cannot be fulfilled.

From here you can elaborate more ...
7 0
3 years ago
arla made a spreadsheet in Excel showing the projected costs for a concert she was putting on. What can Marla enter into cell A1
svp [43]

Marla can enter Food for examble for A11 on the exl page

3 0
2 years ago
Other questions:
  • _____ refers to unsolicited commercial emails, usually sent to a large number of people with little regard to the users interest
    14·1 answer
  • You can avoid culture shock by ____________.
    10·2 answers
  • When performing actions between your computer and one that is infected with a virus, which of the following offers NO risk of yo
    11·1 answer
  • Universal Containers has a sales team focused on renewals. They will use many of the same Opportunity fields as other teams, but
    13·1 answer
  • "Which NET command is used on a Windows PC to establish a connection to a shared directory on a remote server?"
    11·1 answer
  • A technician is configuring the Windows computers on a network to print to a printer that is directly connected to the network v
    8·1 answer
  • Visit the quick access toolbar to find help when looking for certain commands. True False
    15·2 answers
  • Vicky is investigating multiple hacking attempts on her cloud-based e-commerce web servers. She wants to add a front-end securit
    5·1 answer
  • What is Sleep mode? Check all of the boxes that apply.
    12·1 answer
  • if a hacker wants to exploit the TCP three-way handshake, what is the most effective way to go about it?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!