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
dimaraw [331]
3 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]3 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
If you have two tasks x and y, with y being a successor to x, if we mark x as undone (because it needs to be redone for some rea
Ierofanga [76]

Answer:

idk

Explanation:

sorry

7 0
2 years ago
PLEASE HELP there are TWO ANSWERS
pickupchik [31]

Answer:

Pero un campo cuyo tipo de datos es Número solo puede almacenar datos numéricos. ... Por ejemplo, los valores que se almacenan en un campo Texto solo pueden contener ... Para más información, haga clic en los tipos de datos siguientes. ... Controla la conversión de frases en las versiones asiáticas de Windows.

5 0
3 years ago
What is the primary limitation of free versions of antivirus applications?
weqwewe [10]
The correct answer is A because they cant protect in real time
5 0
2 years ago
Carskadon study on starting times for schools concluded that early school starting times cause________.
dimulka [17.4K]

Answer:

Early school starting times cause poor performance on tests, inattention in class, and drowsiness.

Explanation:

Carskadon study on early school starting time showed that it cause increased rate of rapid eye movement sleep in students and they doze off during lecture. Insufficient sleep lessens attentiveness levels in the class which affects students' potential to learn. The study showed that students do not perform well on tests. In addition to the difficulty in learning, there is an increased danger of accidents for those who drive to school due to dizziness.

3 0
2 years ago
After you use the create sequence statement to create a sequence, you can use the _______________________ pseudo column to get t
user100 [1]

After you use the create sequence statement to create a sequence, you can use the NEXTVAL  pseudo column to get the next value in the sequence.

<h3 /><h3>How do you create a sequence?</h3>
  • You must have the Create any sequence system privilege to create a sequence in another user's schema.
  • Specify the schema that will hold the sequence.
  • If you leave out schema, Oracle Database will create the sequence in your own schema. Name the sequence that will be created.
  • Pseudo-columns allow selection, but you cannot edit, update, or remove their values.
  • A pseudo-column is analogous to a function that does not accept any inputs. This section goes over the two pseudo-columns, CURRVAL and NEXTVAL.
  • A pseudo column is a "column" that displays a value when a value is selected but is not one of the table's true columns.
  • Two examples are SysDate and RowID. It is frequently used in tandem with the DUAL table.
  • After you utilize the make sequence statement to make a sequence, you can utilize the NEXTVAL pseudo column to obtain the next value in the sequence.

To learn more about NEXTVAL, refer to:

brainly.com/question/13043887

#SPJ4

3 0
9 months ago
Other questions:
  • Write a public interface named Test with the following behavior:
    5·1 answer
  • How can our perceptions help us to choose the channel for our message?
    5·1 answer
  • If the Account Number field in a record always should display the three characters in the account number in uppercase, then the
    14·1 answer
  • Which cost of purchasing a franchise would you still have if you start your own business​
    12·1 answer
  • Machu Picchu is located in modern day _______<br><br>​
    14·2 answers
  • What are the programming concepts (within or outside the scope of IT210) that you would like to strengthen and delve into furthe
    11·1 answer
  • Gimme Shelter Roofers maintains a file of past customers, including a customer number, name, address, date of job, and price of
    8·1 answer
  • 13) When developing film, how do you dispose of fixer as opposed to developer?
    10·1 answer
  • What is the expression for the resultant value of three capacitance where C1 connected in parallel​
    11·1 answer
  • A diagram of a ten-node network that uses ten routers
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!