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?

Pythonでビット演算

Posted at

はじめに

前回に引き続きビット演算をやっていきます。
動作確認はGoogleColabpratoryで行っています。

論理和

0&0

論理積

0|0

排他的論理和

0^0

まとめ

よくある論理和、論理積、排他的論理和の表を出すコードです。

import numpy as np
import pandas as pd

column_list = ["x", "y", "論理和","論理積", "排他的論理和"]
row_list = ["0", "1", "2", "3"]
data = np.array([[0, 0, 0&0, 0|0, 0^0],
                  [0, 1, 0&1, 0|1, 0^1],
                  [1, 0, 1&0, 1|0, 1^0],
                 [1, 1, 1&1, 1|1, 1^1]])

df = pd.DataFrame(data, row_list, column_list)
print(df)
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?