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?

More than 1 year has passed since last update.

基数変換

Posted at

はじめに

この記事は基数変換の方法についてまとめた記事である。

N → 10

各桁にN進数の重みを掛けて、足す

例(2 → 10)

101.101 =

1 × 2^2 + 1 × 2^0 + 1 × 2^-1 + 1 × 2^-2 =
4 + 1 + 0.5 + 0.125 =

5.625

例(8 → 10)

0.64 =

6 × 8^-1 + 6 × 8^-2 =
0.75 + 0.0625 =

0.8125

10 → N

整数部は基数で割り算を少数部は基数で掛け算を使う

例(10 → 2)

6.375 =

整数部は6

6 / 2 = 3 ... 0
3 / 2 = 1 ... 1
1 / 2 = 0 ... 1

余りを下から並べて110

少数部は0.375

0.375 * 2 = 0.75
0.75 * 2 = 1.5
0.5 * 2 = 1.0

基数を掛けた整数部を上から並べて011

よって、110.011です。

2 → 8

小数点を基準に、3桁ずつ区切って、8進数に変換

1100.01を小数点を基準に、3桁ずつ区切ると、001 100.010になる。
これを8進数に変換すると、1 4 . 2となる。

8 → 2

小数点を基準に、1桁ずつ区切って、2進数に変換

14.2を小数点を基準に、1桁ずつ区切ると、1 4 . 2となる。
これを2進数に変換すると、001 100.010になる。

2 → 16

小数点を基準に、桁ずつ区切って、16進数に変換

1100.01を小数点を基準に、4桁ずつ区切ると、1100.0100になる。
これを16進数に変換すると、C.4

16 → 2

小数点を基準に、1桁ずつ区切って、2進数に変換

C.4を小数点を基準に、1桁ずつ区切ると、 C . 4となる。
これを2進数に変換すると、1100.0100になる。

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?