0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

6、 2進数 ①倫理シフト

Last updated at Posted at 2025-02-21

シフト演算には論理シフトと算術シフトがある。
シフト…ビット列全体を右か左にずらす

論理シフト
…符号を考慮せず、最上位のビットも含めて何も考えずにシフトすること。

☆左論理シフトは元の数の2^n倍
(nは、ずらしたビット数)
 __00101100 (44)

 00101100← ← 左に2ビットシフトさせる。

 __10110000  はみ出たビットは削除して、空になったスペースは0で埋める。

↑元の数値44を2^2(4倍)した176の2進数。

☆右倫理シフトは元の数の1/2^n倍
00101100(44)

→ →00101100 右に2ビットシフトさせる。

00001011 空には0を足して、はみ出たところは削除する。

元の数44を1/2^2倍(1/4倍)した11の2進数。

☆左倫理シフトではみ出した場合
オーバーフロー。そのビット数で表せる範囲を超えてしまった。

☆右倫理シフトではみ出した場合
割り算した結果の余り。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?