如何把二进制数转化为十进制数

方法 1

方法 1 的 2:
按位记数法

WH.shared.addScrollLoadItem(‘7b52ef7247f93dbf8036ecc72cd4bc03’)

WH.performance.clearMarks(‘image1_rendered’); WH.performance.mark(‘image1_rendered’);{“smallUrl”:”https://www.wikihow.com/images_en/thumb/2/28/Convert-from-Binary-to-Decimal-Step-1-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-1-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/2/28/Convert-from-Binary-to-Decimal-Step-1-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-1-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
1
在本例中,我们将把二进制数100110112转换为十进制数。从左到右地列出2的幂。从20开始,结果为”1″。每向右移一位,就对其指数加1。列出的元素个数应等于二进制数的位数。在本例中,10011011有8位数字,因此应列出的8个元素:128, 64, 32, 16, 8, 4, 2, 1
WH.performance.mark(‘step1_rendered’);

WH.shared.addScrollLoadItem(‘db195b54385d6992770430c037a0d819’)

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/96/Convert-from-Binary-to-Decimal-Step-2-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-2-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/9/96/Convert-from-Binary-to-Decimal-Step-2-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-2-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
2
把二进制数上的每一位数字对应地写到列表下方。

WH.shared.addScrollLoadItem(’70e75732a3f0e02bd66a692b3e1c037c’)

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/e/e2/Convert-from-Binary-to-Decimal-Step-3-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-3-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/e/e2/Convert-from-Binary-to-Decimal-Step-3-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-3-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
3
从右边开始,画出线条,用于把二进制数中连续的数字和其上方的2的幂连接起来。从右边开始,画一条线,把二进制数的第一个数字和2的第一个幂值连接起来。然后,画一条线,把二进制数的第二个数字和2的第二个幂值连接起来。依次类推,画出线条把每一个数字和对应的幂值连接起来。

WH.shared.addScrollLoadItem(‘c9e5d8493457fb0dd891733f210aedb7’)

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/e/ef/Convert-from-Binary-to-Decimal-Step-4-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-4-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/e/ef/Convert-from-Binary-to-Decimal-Step-4-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-4-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
4
扫描二进制数中的每一位数字。如果对应的数字为1,则在线条下方写下对应的2的幂值。如果对应的数字为0,则在线条下方写下0。

WH.shared.addScrollLoadItem(‘683caed6bdbb406f9caa8a45b228526e’)

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/16/Convert-from-Binary-to-Decimal-Step-5-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-5-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/1/16/Convert-from-Binary-to-Decimal-Step-5-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-5-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
5
把线条下方的数相加。所得总和为155。这就是二进制数10011011对应的十进制数。或者写成基数下标的形式:

WH.shared.addScrollLoadItem(’52dac5fecaa98deaf66edae02c3e3035′)

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/93/Convert-from-Binary-to-Decimal-Step-6-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-6-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/9/93/Convert-from-Binary-to-Decimal-Step-6-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-6-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
6
以上方法熟悉后,你将记得2的每一个幂值,因此可以省略第1步。

WH.ads.addBodyAd(‘method_ad_1’)
WH.ads.addBodyAd(‘mobilemethod_ad_1’)广告

方法 2

方法 2 的 2:双倍法

1
该方法不需要使用幂运算。因此,当你通过心算转换较大的数值时,该方法更简单,因为你只需要记下部分和。

WH.shared.addScrollLoadItem(‘22438dc732220a48517ad1d51d6fa877’)

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/1d/Convert-from-Binary-to-Decimal-Step-8-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-8-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/1/1d/Convert-from-Binary-to-Decimal-Step-8-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-8-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
2
从给定二进制数最左边的数字开始。对于每一位数字,你向右移动,对之前所得总和乘以2并加上当前数值。例如,把10110012转换为十进制数,我们将采用如下步骤:

WH.shared.addScrollLoadItem(‘21240bb89aed95bd670f453fa4205e59’)
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/7/7b/Convert-from-Binary-to-Decimal-Step-9-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-9-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/7/7b/Convert-from-Binary-to-Decimal-Step-9-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-9-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
3
1011001 → 0 * 2 + 1 = 1

WH.shared.addScrollLoadItem(‘2e7887220886f390a4cb86aa9d9de2e4’)
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/88/Convert-from-Binary-to-Decimal-Step-10-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-10-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/8/88/Convert-from-Binary-to-Decimal-Step-10-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-10-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
4
1011001 → 1 * 2 + 0 = 2

WH.shared.addScrollLoadItem(’77a1425d98f50e9bfe0b89b3a9b5b88e’)
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/bd/Convert-from-Binary-to-Decimal-Step-11-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-11-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/b/bd/Convert-from-Binary-to-Decimal-Step-11-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-11-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
5
1011001 → 2 * 2 + 1 = 5

WH.shared.addScrollLoadItem(‘f288663f8aee721668084b2196cfb005’)
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/d1/Convert-from-Binary-to-Decimal-Step-12-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-12-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/d/d1/Convert-from-Binary-to-Decimal-Step-12-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-12-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
6
1011001 → 5 * 2 + 1 = 11

WH.shared.addScrollLoadItem(‘975f89add24698082c46881649618429’)
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/6/61/Convert-from-Binary-to-Decimal-Step-13-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-13-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/6/61/Convert-from-Binary-to-Decimal-Step-13-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-13-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
7
1011001 → 11 * 2 + 0 = 22

WH.shared.addScrollLoadItem(‘843c44b59bce0784e06b0c1c89e4ffb6’)
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/41/Convert-from-Binary-to-Decimal-Step-14-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-14-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/4/41/Convert-from-Binary-to-Decimal-Step-14-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-14-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
8
1011001 → 22 * 2 + 0 = 44

WH.shared.addScrollLoadItem(’53f13bb0c77babfc81034a38dff6e40d’)
{“smallUrl”:”https://www.wikihow.com/images_en/thumb/f/f8/Convert-from-Binary-to-Decimal-Step-15-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-15-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/f/f8/Convert-from-Binary-to-Decimal-Step-15-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-15-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
9
1011001 → 44 * 2 + 1 = 8910

WH.shared.addScrollLoadItem(‘16846a04e655dde8e34d06957485c97a’)

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/c/c9/Convert-from-Binary-to-Decimal-Step-16-Version-2.jpg/v4-460px-Convert-from-Binary-to-Decimal-Step-16-Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/c/c9/Convert-from-Binary-to-Decimal-Step-16-Version-2.jpg/v4-728px-Convert-from-Binary-to-Decimal-Step-16-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”

“}
10
和按位记数法一样,本方法经调整后也能把基于任何基数的数转换为十进制数。在这里采用双倍法因为这里给定的数是以2为基数的。如果给定的数是基于不同的基数,则应本方法中的2换成对应的基数。例如,如果给定数是以37为基数,则你在计算时应把*2换为*37。而最终的结果则总是对应的十进制数(基数10)。 🙂

WH.ads.addBodyAd(‘mobilemethod_ad_2’)广告

发表评论

您的电子邮箱地址不会被公开。