Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Multiply by Two Using Bitwise
00:00
5 left

Multiply by Two Using Bitwise

EasyPython

Problem

Using bitwise operations, how would you multiply a given number by 2?

Implement def multiply_by_two(number): and return the resulting integer. The solution must use bitwise operations rather than *, and it must work for zero, positive integers, and negative integers.

Constraints

  • number is an integer
  • -10^18 <= number <= 10^18
  • Do not use the multiplication operator

Function Signature

def multiply_by_two(number):
Interviewer

Your question is Multiply by Two Using Bitwise. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.