2進製到10進制在線轉換工具

2進制2

10進制10

16進制16

8進制8

關於2進製到10進制在線轉換工具:

這個在線2進製到10進制轉換工具可幫助您將一個八進制數轉換為十進制數.

二進制(Binary):

二進制只有2種字符(0, 1) . 4位二進製字符可以表示1位十六進制數字, 3位二進製字符可以表示1位八進制數字.二進制是最接近彙編語言的數字系統.

十進制(Decimal):

十進制數字系統(也稱為阿拉伯語)有10種字符,包括(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) ,它是我們日常生活中使用最多的數字系統.

comic binary to decimal

如何進行2進製到10進制轉換?

對錶示為以下圖片的n位2進制數字:

dn-1dn-2...d2d1d0

對於數字的每一位,乘以2的對應位數次方.

Decimal Output = dn-1 × 2n-1 + ... + d1 × 21 + d0 × 20

例1: 2進制數字"1101" 轉換為10進制數字:

Decimal Output = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 13

Example 2: 2進制數字"0.101" 轉換為10進制數字:

Decimal Output = 0 × 20 + 1 × 2-1 + 0 × 2-2 + 1 × 2-3 = 0.625

2進製到10進制轉換錶:

2進制 10進制 2進制 10進制
1 1 10101 21
10 2 10110 22
11 3 10111 23
100 4 11000 24
101 5 11001 25
110 6 11010 26
111 7 11011 27
1000 8 11100 28
1001 9 11101 29
1010 10 11110 30
1011 11 11111 31
1100 12 100000 32
1101 13 100001 33
1110 14 100010 34
1111 15 100011 35
10000 16 100100 36
10001 17 100101 37
10010 18 100110 38
10011 19 100111 39
10100 20 101000 40

鏈接:

維基百科(二進制): https://en.wikipedia.org/wiki/Binary_number

維基百科(十進制) https://en.wikipedia.org/wiki/Decimal

用Python進行2進製到10進制轉換:

def binary_to_decimal(binary_str):
    decimal_number = int(binary_str, 2)
    return decimal_number


binary_input = '1101'
decimal_output = binary_to_decimal(binary_input)
print('decimal result is:{0}'.format(decimal_output))

-------------------
decimal result is:13

用Java進行2進製到10進制轉換:

public class NumberConvertManager {
    public static int binary_to_decimal(String binary_str) {
        return Integer.parseInt(binary_str, 2);
    }

    public static void main(String[] args) {
        String binary_input  = "1101";
        int decimal_output = binary_to_decimal(binary_input);
        System.out.println("decimal result is:" + decimal_output);
    }
}

-------------------
decimal result is:13