如果負數從-31到-1,那麼我想將其表示爲111XXXXX格式。 我嘗試做它用「和」位運算符:按位「和」操作進入kotlin
println("0b00011111 & 0xe0 is ${0b00011111 and 0xe0}")
println("31 & 0xe0 is ${31 and 0xe0}")
println("0b00011111 & 0b11100000 is ${0b00011111 and 0b11100000}")
但結果始終是0。我是在哪裏犯這樣的錯誤?
你提到你的實際結果(0),但你期望的結果是什麼? – mfulton26
我預計結果將是0b11111111或255。 –
哦!我明白。我使用錯誤的操作符。這個問題可能會被關閉。 –