转换一个从基地B1到B2基本不使用任何中间基地 [英] Convert a number from Base B1 to Base B2 without using any intermediate base
问题描述
有没有办法转换成一个数字基地B1到B2基本不使用任何中间位置。
Is there a way Convert a number from Base B1 to Base B2 without using any intermediate base.
例如:
214基地5个基地16而不转换它首先十进制数,然后十进制为十六进制。
214 from base 5 to base 16 without converting it first to decimal and then decimal to hexadecimal.
-
感谢
阿洛克氪。
推荐答案
要转换214 <子> base5 立足16不需要中间基地,你只需要知道如何直接计算基地5
To convert 214base5 to base 16 without an intermediate base, you "just" have to know how to calculate directly in base 5.
首先,你需要什么样的基地16个数字是基5表(在转换基地10到基地16,你需要一个类似的表,它只是一个更容易保持你的头!)。这个表很容易创建 - 只需从0开始,并增加每个基地5行,直到你达到 F
在基地16
First, you need a table of what the base 16 digits are in base 5 (you need a similar table when converting base 10 to base 16, it's just that that one is easier to keep in your head!). This table is easy to create - just start at 0 and increment each base 5 row until you reach f
in base 16.
base 16 | base 5
--------+--------
0 | 0
1 | 1
2 | 2
3 | 3
4 | 4
5 | 10
6 | 11
7 | 12
8 | 13
9 | 14
a | 20
b | 21
c | 22
d | 23
e | 24
f | 30
现在你只需要反复16分频(即31 <子> base5 )。我们现在回顾我们小学时,用长除法(如果这似乎很难,那是因为没有人让你学会在基地5次的桌!):
Now you just need to repeatedly divide by 16 (which is 31base5). We now recall our primary school days, and use long division (if this seems hard, it's because no-one made you learn your times-tables in base 5!):
步骤1:
______
31 ) 214
步骤2:
3
______
31 ) 214 -
143
步骤3:
3
_____
31 ) 214 -
143
----
21
所以214 <子> base5 31 <子> base5 分的结果是3 <子> base5 其余21 <子> base5 。
So the result of 214base5 divided by 31base5 is 3base5 remainder 21base5.
这意味着,在base16最低显著数字是21 <子> base5 ,您可以在表中找到为b <子> base16 。分工的结果是3 <子> base5 - 如果这是大于30 <子> base5 那么我们将再次分裂 - 但它不是,所以这意味着最显著数字是(用该表再次)3 <子> base16 。
This means that the least significant digit in base16 is 21base5, which you can find in the table is bbase16. The result of the division is 3base5 - if this was greater than 30base5 then we would divide again - but it's not, so this means the most significant digit is (using the table again) 3base16.
因此,答案是214 <子> base5 = 3B <子> base16 。
So the answer is 214base5 = 3bbase16.
这篇关于转换一个从基地B1到B2基本不使用任何中间基地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!