LoginSignup
2
1

More than 5 years have passed since last update.

長いビット列を16進数にする

Posted at

はじめに

長いビット列を16進数にする方法を記載します。

Excel

Excelでビット列を16進数にするには BIN2HEX を使います。
ただし ビット長は 9ビットまでです。9ビットを超えると正常に動作しません。

1.JPG

Python

Pythonを使うと 9ビットを超えるビット列を扱えます。
ビット列は0bではじめます。formatを使うことで桁数を合わせた16進数にできます。
例を示します。
0b 0000 0011 0010 0000 0000 0000 0000 0000を8桁の16進数にする例です。

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> '0x{0:08x}'.format(0b00000011001000000000000000000000)
'0x03200000'
2
1
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
2
1