エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Programming tidbits
Right shifting of positive integers leads to truncation: 9 >> 1 4 9 >> 2 2 Interestingly, right s... Right shifting of positive integers leads to truncation: 9 >> 1 4 9 >> 2 2 Interestingly, right shift for negative integers also leads to truncation: -9 >> 1 -5 -9 >> 2 -3 If we combine the effects, we can get rounding up during right shift for positive integers: -(-9 >> 1) 5 -(-9 >> 2) 3 So here is a C function for rounding up while shifting: int rightShiftRoundUp(int x, int n){ return - ( -x >>