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.
これが質問です
符号ビットを取得するために 31 だけ右にシフトすることを考えましたが、技術的に 0 を正と負にすることはできませんか?
あなたはこのように試すことができます32 bit int:-
32 bit int
(x >> 31) | (((~x + 1) >> 31) & 1)