Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
"~" 演算子は Java で次のように何をしますbyte b =~5 + 1か?
byte b =~5 + 1
結果が標準出力に送信されるSystem.out.print(b)と出力されます'-5'が、その理由や意味がわかりません。
System.out.print(b)
'-5'
これはビット単位の補数演算子です。Java は2 の補数を使用して負の数を表すため、~x + 1は と同等-xです。
~x + 1
-x