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
You are being hired as the director of IT for a small firm that does retail trade business, and you will be the source of knowle
Orlov [11]

Director of IT role is major decision maker or any IT related issue such as network security, database, network issues etc. As policy to one to one end user and it department, which should cover as follows.

1. End-user is not allowed to share files or media files to any user through email or social media.

2. Login password should not be changed without IT approval of pc or   workstation or laptop.  Once changes password should be shared to IT department.

3. Sharing password Wi-Fi or access point to outsiders to be avoided.

4. Connecting usb drive or flash drive to workstation or laptop,

5. Own laptop or smartphone should not be connected to office network.

6. If workstation or desktop or laptop is effected with virus immediately to be reported to IT department.

5 0
3 years ago
A technician is configuring a new SOHO multifunction wireless router at a customer's location to provide network access to sever
Leno4ka [110]

Answer:

B. Change the router's default administrative password

Explanation:

The best way to prevent any unauthorized use is to change the password to something more secure using 12 minimum characters and including number, symbols, upper and lower case.

4 0
4 years ago
If a computer system does not have a graphics card installed in a motherboard's PCIe slot, which component handles video calcula
Klio2033 [76]

Answer:The Cpu or a chip on the Motherboard

Explanation: yore welcome

5 0
4 years ago
Francis works in the human resources division of a large oil and gas company in Texas. Francis' tasks include maintaining payrol
Maru [420]

Answer:

A. Information MIS infrastructure

Explanation:

An Information MIS infrastructure supports how important information is maintained and secured in an organization. It also supports the day to day operations of an organization, in this case, which includes maintaining payroll and vacation records, employment histories, and benefits information. Information MIS infrastructure also provides measures for backup and disaster recovery plans and the business continuity plan. On the other hand, Agile MIS infrastructure supports change within an organization's business processes while sustainable MIS infrastructure refers to the sustainable use and disposal of technology in an environmentally friendly manner.

6 0
4 years ago
What are the pros and cons of using the internet in a medical office setting?
Shkiper50 [21]
Pros: are doctors are able to educate themselves in order to diagnose a patient, it's fast and convenient to put in records, medical facilities can transfer information from different locations etc.

Cons: the system can breached, this could leak health and personal information from patients, and the power could go down, delaying the use of signing in patients and etc
5 0
3 years ago
Other questions:
  • In which area of engineering does material selection play a vital role a design optimization b forensic engineering c mechanical
    6·1 answer
  • By default, PowerPoint ends a slide show with a black slide. <br> a. True<br> b. False
    5·2 answers
  • What doyou mean by process model and project model?
    6·1 answer
  • You currently are IT support for Richman Investments, a brokerage firm that employs 20 brokers. Each broker has their own client
    12·1 answer
  • Patronage of most Medieval musicians was supplied by the
    13·1 answer
  • Big Project, Giving 5 stars, a Thanks, 80 points, and Branliest to whoever answers them correctly
    9·2 answers
  • Choose the correct definition for Conditional Statement A. Affects the sequential flow of control by executing different stateme
    6·2 answers
  • Create a public class Dog that stores a single double age set by the constructor. (Reject negative ages using assert.) Dog shoul
    13·1 answer
  • In this exercise, you are asking the user to set a alpha numeric password for any website. Put some conditions.
    8·1 answer
  • Helllp me you will git 16 points
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!