id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > may25_2018_APSL_bitShiftRightThenLeft
prev  |  next  |  chance

Write a method that performs a bit-wise logic-shift-right, then a bit-wise logic-shift-left on the binary representation of the non-negative integer input parameter. Return the integer representing the resulting binary number. For example, if the input parameter is 23, the binary representation for that is 10111. After logic-shifting-right, you would have 1011. Next you would logic-shift-left resulting in 10110. The decimal number for 10110 is 22, so you would return a 22. The right-most digit will always be a zero after performing the logic-shift left. Look at the test data for additional examples. You may assume that the input parameter is small enough not to produce an integer "overflow". You may NOT use ANY strings or string methods.


may25_2018_APSL_bitShiftRightThenLeft(23) → 22
may25_2018_APSL_bitShiftRightThenLeft(0) → 0
may25_2018_APSL_bitShiftRightThenLeft(472) → 472

...Save, Compile, Run (ctrl-enter)

public int may25_2018_APSL_bitShiftRightThenLeft(int num) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 280

Copyright Nick Parlante 2017 - privacy