about | help | code help+videos | done | prefs |
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) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 280
Copyright Nick Parlante 2017 - privacy