i<<-1和i<<31 的結果一樣
1 “-1”表示成補碼是1111 ….11 1111 ,31是 0000 …0001 1111,,他們的後五位是一樣的。
2 Interger的移位運算只注意後5位,看註釋
Note also that rotation by any multiple of 32 is a no-op, so all but the last five bits of the rotation distance can be ignored, even if the distance is negative:
總結:將負數寫爲補碼,這個數的低5位便是其真正移位的數字
移位運算符操作數是負數的處理方式
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Git使用經驗總結4-撤回上一次本地提交
harlee44
2024-05-08 14:31:14
Git使用經驗總結5-修改提交信息
harlee44
2024-05-08 14:31:14
php-strpos 判斷一個字符串是否存在於另一個字符串中
流年中渲染了微笑
2024-05-08 14:30:04
編程隨想曲週刊(第75期)
Simle
2024-05-08 14:27:23
編程隨想曲週刊(第76期)
Simle
2024-05-08 14:27:23
DeepFilterNet復現
Kevin_naticl
2024-05-08 14:25:33
同事使用 insert into select 遷移數據,開開心心上線,上線後被公司開除!
Java技術棧
2024-05-08 14:21:32
多語言實現 - 世界語言對應的簡寫
阿 軍
2024-05-08 14:15:12
《最新出爐》系列入門篇-Python+Playwright自動化測試-44-鼠標操作-上篇
北京-宏哥
2024-05-08 14:14:42
Docker 安裝 Elasticsearch 和 kibana
李*靜波
2024-05-08 14:14:21
算法~PBKDF2-SHA讓密碼更安全
張佔嶺
2024-05-08 14:12:31
Computer Basics - Top 10 keyboard shortcuts everyone should know
emanlee
2024-05-08 14:10:30
24小時熱門文章