Dim*_*tri 2 scala bit-manipulation
我正在定义一个简单的函数来执行一些按位操作:
def getBit(num:Int, i:Int):Boolean = (num & (1 << i) != 0)
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误:
<console>:7: error: overloaded method value & with alternatives:
(x: Long)Long <and>
(x: Int)Int <and>
(x: Char)Int <and>
(x: Short)Int <and>
(x: Byte)Int
cannot be applied to (Boolean)
def getBit(num:Int, i:Int):Boolean = (num & (1 << i) != 0)
Run Code Online (Sandbox Code Playgroud)
为什么我不能使用&运营商?我该如何解决这个错误?
| 归档时间: |
|
| 查看次数: |
3714 次 |
| 最近记录: |