You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases bitwise shifts (<<. >> and >>>) for certain numeric types return value of incorrect type. For instance:
scala>valint=1
int:Int=1
scala>vallong=2L
long:Long=2
scala> int << long
res0:Int=4
scala> int <<2L
res1:Int=4
scala>1<< long
res2:Int=4
scala>1<<2L
res3:Long=4
scala>1.toInt << long
res4:Int=4
scala>1.toInt <<2L
res5:Int=4
res3: This 1 of type Int has been changed to Long.
In some cases bitwise shifts (<<. >> and >>>) for certain numeric types return value of incorrect type. For instance:
res3: This 1 of type Int has been changed to Long.
As Jason Zaugg said (see https://groups.google.com/forum/#!topic/scala-internals/nr0HOhXjrPs ):
This is related to constant folding.
In the implementation, we have:
The wider of the operands type is used.
For other arithmetic operations, this lines up with the regular signatures of the methods. For example:
But this doesn't hold for the shifts:
The text was updated successfully, but these errors were encountered: