Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def leftRotate(w: Long, k: Int): Long =
- val wBinary = (0 to 63).toArray.map(j => (w >> 63 - j) & 1).flatMap(b => "%d".format(b))
- println(new String(wBinary))
- var j = 0
- val rArray = Array.fill(64)('1')
- while j <= 63 do
- rArray((j + k)%64) = wBinary(j)
- j += 1
- val rString = new String(rArray)
- println(rString)
- java.lang.Long.parseLong(rString.reverse, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement