如何从十进制转换为二进制?
数制是表示数字的方式之一。每个数字系统都有自己的基数或基数。例如,二进制、八进制、十进制和十六进制数字系统是一些数字系统,也用于微处理器编程。
- 二进制数 - 以 2 为底
- 八进制数 - 以 8 为基数
- 十进制数 - 以 10 为底
- 十六进制数 - 以 16 为基数
这些数字很容易从一个系统转换到其他系统。可以将十进制转换为二进制,十进制转换为十六进制,十进制转换为八进制,反之亦然。在这里,让我们学习如何将十进制转换为二进制数字系统以及转换步骤和示例。
十进制到二进制转换
在学习如何在数制中将十进制转换为二进制之前,我们先来了解什么是十进制数制,什么是二进制数制。
十进制数系统
The number system that has a base value of 10 is called Decimal Number System. Decimal Numbers are consist of the following digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
二进制数制
A binary Number System is a base-2 number system that uses two states 0 and 1 to represent a number. For example: 01, 111, etc.
所有的十进制数都有对应的二进制数。这些二进制数用于计算机应用程序并用于编程或编码目的。这是因为二进制数字 0 和 1 只有计算机才能理解。
十进制到二进制转换的步骤
对于将十进制数转换为二进制数,可以使用不同的方法,例如公式、除法等。在这里,使用余数公式。使用十进制到二进制公式将十进制数转换为二进制数的步骤如下,
第 1 步:将给定的十进制数除以 2,求余数 (R i )。
步骤2:现在将上述步骤中获得的商(Q i )除以2,求余数。
步骤 3:重复上述步骤 1 和 2,直到获得 0 作为商。
第 4 步:按以下方式写下余数:先写最后一个余数,然后以相反的顺序写余数(R n ,R (n – 1) .... R 1 )。因此将获得给定十进制数的二进制转换。
让我们通过一些示例来学习如何使用十进制到二进制公式将十进制数转换为二进制数。
示例问题
问题1:使用十进制转二进制公式,将十进制的2转换为二进制数。
解决方案:
Using decimal to binary formula,
Step 1: Divide the number by 2, find the remainder:
2 ÷ 2 gives Q1 = 1, R1 = 0
Step 2: Divide Q1 by 2, find the remainder:
1 ÷ 2 gives Q2 = 0, R2 = 1
Step 3: Write down the remainder in the following manner: the last remainder is written first, followed by the rest in the reverse order (Rn, R(n – 1) …. R1), this is the binary conversion of the given decimal number: 10
Answer: Hence, 2 as binary is (10)2
问题2:使用十进制到二进制的公式,将十进制的3转换为二进制数。
解决方案:
Using decimal to binary formula,
Step 1: Divide the number by 3, find the remainder.
3 ÷ 2 gives Q1 = 1, R1 = 1
Step 2: Divide Q1 by 2, find the remainder.
1 ÷ 2 gives Q2 = 0, R2 = 1
Step 3: Write down the remainder in the following manner: the last remainder is written first, followed by the rest in the reverse order (Rn, R(n – 1) …. R1), this is the binary conversion of the given decimal number: 11
Answer: Hence, 3 as binary is (11)2
问题3:使用十进制转二进制公式,将十进制的4个转换成二进制数。
解决方案:
Using decimal to binary formula,
Step 1: Divide the number by 4, find the remainder.
4 ÷ 2 gives Q1 = 2, R1 = 0
Step 2: Divide Q1 by 2, find the remainder.
2 ÷ 2 gives Q2 = 1, R2 = 0
Step 3: Divide Q2 by 2, find the remainder.
1 ÷ 2 gives Q3 = 0, R3 = 1
Step 4: Write down the remainder in the following manner: the last remainder is written first, followed by the rest in the reverse order (Rn, R(n – 1) …. R1), this is the binary conversion of the given decimal number: 100
Answer: Hence, 4 as binary is (100)2
问题4:使用十进制转二进制公式,将十进制的5转换为二进制数。
解决方案:
Using decimal to binary formula,
Step 1: Divide the number by 5, find the remainder.
5 ÷ 2 gives Q1 = 1, R1 = 1
Step 2: Divide Q1 by 2, find the remainder.
2 ÷ 2 gives Q2 = 1, R2 = 0
Step 3: Divide Q2 by 2, find the remainder.
1 ÷ 2 gives Q3 = 0, R3 = 1
Step 4: Write down the remainder in the following manner: the last remainder is written first, followed by the rest in the reverse order (Rn, R(n – 1) …. R1), this is the binary conversion of the given decimal number: 101
Answer: Hence, 5 as binary is (101)2
问题 5:使用十进制转二进制公式,将十进制的 6 转换为二进制数。
解决方案:
Using decimal to binary formula,
Step 1: Divide the number by 6, find the remainder.
6 ÷ 2 gives Q1 = 2, R1 = 0
Step 2: Divide Q1 by 2, find the remainder.
3 ÷ 2 gives Q2 = 1, R2 = 1
Step 3: Divide Q2 by 2, find the remainder.
1 ÷ 2 gives Q3 = 0, R3 = 1
Step 4: Write down the remainder in the following manner: the last remainder is written first, followed by the rest in the reverse order (Rn, R(n – 1) …. R1), this is the binary conversion of the given decimal number: 110
Answer: Hence, 6 as binary is (110)2
问题 6:使用十进制转二进制公式,将十进制的 7 转换为二进制数。
解决方案:
Using decimal to binary formula,
Step 1: Divide the number by 7, find the remainder.
7 ÷ 2 gives Q1 = 3, R1 = 1
Step 2: Divide Q1 by 2, find the remainder.
3 ÷ 2 gives Q2 = 1, R2 = 1
Step 3: Divide Q2 by 2, find the remainder.
1 ÷ 2 gives Q3 = 0, R3 = 1
Step 4: Write down the remainder in the following manner: the last remainder is written first, followed by the rest in the reverse order (Rn, R(n – 1) …. R1), this is the binary conversion of the given decimal number: 111
Answer: Hence, 7 as binary is (111)2.
问题 7:使用十进制转二进制公式,将十进制的 8 转换为二进制数。
解决方案:
Using decimal to binary formula,
Step 1: Divide the number by 8, find the remainder.
8 ÷ 2 gives Q1 = 2, R1 = 0
Step 2: Divide Q1 by 2, find the remainder.
4 ÷ 2 gives Q2 = 1, R2 = 0
Step 3: Divide Q2 by 2, find the remainder.
2 ÷ 2 gives Q3 = 0, R3 = 0
Step 4: Divide Q3 by 2, find the remainder.
1 ÷ 2 gives Q4 = 0, R4 = 1
Step 5: Write down the remainder in the following manner: the last remainder is written first, followed by the rest in the reverse order (Rn, R(n – 1) …. R1), this is the binary conversion of the given decimal number: 1000
Answer: Hence, 8 as binary is (1000)2