Q:

bitwise shift right with long not equaling zero?

I was playing in the REPL, and I see this behavior for >> and >>>. It seems that a Long should occupy 64 bits, so shifting right by 64 should always zero out the number.
scala> 64 >> 64
res22: Int = 64

scala> 64 >> 65
res23: Int = 32

scala> 64 >> 66
res24: Int = 16

scala> 64 >> 67
res25: Int = 8

scala> 64 >> 68
res26: Int = 4

scala> 64 >> 69
res27: Int = 2

scala> 64 >> 70
res28: Int = 1

scala> 64 >> 71
res29: Int = 0

scala> 64 >>> 64
res30: Int = 64

scala> 64 >>> 65
res31: Int = 32

What is this behavior in Scala? 

A:

Scala takes the right hand and applies it modulo the word size of the left hand operand. You will get the same result for Int using right hand values of 32, 64 and 128.
scala> 64 >> 64
res0: Int = 64

scala> 64 >> 1
res1: Int = 32

scala> 64 >> 32
res2: Int = 64

scala> 8 >> 32
res3: Int = 8

scala> 8 >> 64
res4: Int = 8

scala> 8 >> 128
res5: Int = 8

scala> 64L >> 64
res6: Long = 64

scala> 64L >> 32
res7: Long = 0

