answer.
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
dimaraw [331]
2 years ago
6

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation

.Note: The given integer is guaranteed to fit within the range of a 32-bit signed integer. You could assume no leading zero bit in the integer’s binary representation.
Computers and Technology
1 answer:
EleoNora [17]2 years ago
5 0

Answer:

var findComplement = function(num) {

   

   var start = false;

       for (var i = 31; i >= 0; --i) {

           if (num & (1 << i)) {//find the leftmost hightest bit 1 and start from there

               start = true;

           }

           if (start) {

               

               num ^= (1 << i);

             

           }

       }

       return num;

};

var findComplement = function(num) {

   var bits = num.toString(2);

   var complement = '';

   for(var i=0;i<bits.length;i++)

   {

       complement += (bits[i]==1?0:1);

   }

   return parseInt(complement,2);

};

Explanation:

The javascript code above would accept a number in the variable complemnt and using the parseint keyword, it converts it to a binary value of that number.

Each bit is converted from the least to the most significant bit, then it is returned to the find compliment function and converted back to an integer.

You might be interested in
Which of the following is not true of how computers represent complex information
mote1985 [20]

Answer: c. Depending on context the same sequence of bits may represent different types of information.

Explanation:

The options for the question are:

A. Computing devices use patterns of bits to represent complex information

B. Abstraction helps represent complex information by surfacing complexity that might otherwise be hidden

C. Depending on context the same sequence of bits may represent different types of information

D. Common abstractions that are represented by computing devices include numbers, characters, and color.

The following are true of how computers represent complex information:

• Computing devices use patterns of bits to represent complex information

• helps represent complex information by surfacing complexity that might otherwise be hidden

• Common abstractions that are represented by computing devices include numbers, characters, and color.

Therefore, the option that is not true of how computers represent complex information is that "depending on context the same sequence of bits may represent different types of information".

5 0
2 years ago
Read 2 more answers
The java compiler requires that a source file use the ________ filename extension question 3 options: 1) .class 2) .h 3) .java
scoray [572]
<span>3) .java Let's look at the three options and see why they're right or wrong. 1) .class This is the file extension that the java compiler used to the compiled output from the compiler. So it's the wrong answer. 2) .h This is the file extension used for C and C++ header files. So once again, not the right answer. 3) .java This is the correct extension for a java source file to be compiled.</span>
6 0
2 years ago
System design is the determination of the overall system architecture-consisting of a set of physical processing components, ___
Alenkinab [10]

Answer:

C) Hardware, Software, People

Explanation:

System design is the determination of the overall system architecture-consisting of a set of physical processing components, Hardware, Software, People and the communication among them-that will satisfy the system’s essential requirements.

5 0
2 years ago
Read 2 more answers
Why is continual user involvement a useful way to discover system requirements? Under what conditions might it be used? Under wh
True [87]

Answer:

continual user involvement gives the flexibility to analyze the requirements in right direction. because there is continuous meetings with the end user and he can provide right direction or avoids wrong interpretation of the requirement

Explanation:

continual user involvement is useful when we are following agile methodology where we are building complex systems. it is not useful for simple sytems and following waterfall methodology

7 0
2 years ago
The navigation bar on the left side of ____ view contains commands to perform actions common to most office programs.
kondor19780726 [428]

Answer:

The navigation bar on the left side of File view  contains commands to perform actions common to most office programs.

Explanation:

It enable all kinds of operations such as opening a file, closing a file, saving the file, saving a file with a different name, listing recently opened document, etc.

The open option enable us to open an existing file, all the recent files will be listed in the recent option and there are no files opened newly or if the data are cleared often, then it will be empty.

A file can be opened and saved with the different name so that the recent change will be saved in the new file and there will be presence of existing file too.

4 0
2 years ago
Other questions:
  • ​identify a text-level element used to mark generic run of text within the document.
    15·1 answer
  • Adrian has decided to create a website to catalog all the books he has in his personal library. He wants to store this informati
    11·2 answers
  • Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the
    12·1 answer
  • You can press ____ to move the focus through the controls of the form. [page down] [tab] [f5] [f12]
    10·1 answer
  • A device has an IP address of 10.1.10.186 and a subnet mask of 255.255.255.0. What is true about the network on which this devic
    9·1 answer
  • What three requirements are defined by the protocols used in network communications to allow message transmission across a netwo
    11·1 answer
  • Based on virtualization technologies, how many types can we classify them? Please give a brief statement on each of them?
    14·1 answer
  • Design and implement an algorithm that gets as input a list of k integer values N1, N2,..., Nk as well as a special value SUM. Y
    12·1 answer
  • Write a complete Java program that: Prompts an employee to enter the number of hours that they have worked in a given week and s
    14·1 answer
  • On the Direct Marketing worksheet, create appropriate range names for Design Fee (cell B8), Cost Per Ad (cell B9), Total Clicks
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!