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?

4. 基数変換② 2進数と8進数、16進数の基数変換

Last updated at Posted at 2025-02-10

8進数は2の3乗
16進数は2の4乗

2進数を8進数にする場合
2進数を3桁に区切り(ない桁は0を補う)。
区切った1つ1つが8進数の1桁にあたる。
2進数1101.01→001 101.010
区切り単位でそれぞれ10進数に直す
001→(0×4)+(0×2)+(1×1)=1
101→(1×4)+(0×2)+(1×1)=5
010→(0×4)+(1×2)+(0×1)=2
これをくっつけて8進数に。15.2

2進数を16進数に直す場合
2進数を4桁ごとに区切り、区切り単位でそれぞれ10進数に直す。(4桁ないところは0を補う)
2進数1101.01→1101.0100
1101→(1×8)+(1×4)+(0×2)+(1×1)=13→16進数に直すとD
0100→(0×8)+(1×4)+(0×2)+(0×1)=4
16進数の場合は9の次にA〜Fが来る16進表記になる。
くっつけて、D.4

反対に8進数や16進数を2進数に基数変換する場合は、逆の流れで、
8進数1桁を2進数3桁に
16進数1桁を2進数4桁に、と分解する。

8進数15.2を2進数に
1→001、5→101、小数点 2→010
001101.010両端から余計な0を取ると、
1101.01

16進数D.4を2進数に
D→1101 小数点 4→0100
1101.0100→1101.01

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?