2进制到10进制在线转换工具

2进制2

10进制10

16进制16

8进制8

如何进行2进制到10进制转换?

dn-1dn-2...d2d1d0

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

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

用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```