根据序列和源库确定目标库中的任意数字范围
如果我有一个函数f来计算基数b中的数字序列的元素m,那么通常可以编写一个函数< em>g 计算基数 c 中相应序列的元素 n ?
作为一个人为的示例,假设 f 生成二进制,g 生成十六进制:
f(m) → 1, 0, 1, 0, 1, 0, 1, 0, ... g(n) → A, A, ...
现在假设 f 的基数为 5,而 g 的基数为 5 > 的基数为 6。基数不共享公因数,这意味着在目标基数中表示源基数中的数字所需的位数是小数 (6⁄5)。是否可以仅使用相应的 c⁄b 来确定 g 中的单个数字> 位 f 中的数字?
请注意,从第一个元素开始公式与执行小数从 b 到 c 的标准转换相同,但我想要目标序列的任意元素,就像我可以检索源的任意元素一样。
If I have a function f that computes element m of a sequence of digits in base b, is it in general possible to write a function g that computes element n of the corresponding sequence in base c ?
As a contrived example, say f produces binary and g produces hexadecimal:
f(m) → 1, 0, 1, 0, 1, 0, 1, 0, ... g(n) → A, A, ...
Now say f is in base 5 and g is in base 6. The bases don't share a common factor, which means that the number of digits required to represent a number from the source base in the target base is fractional (6⁄5). Is it possible to determine a single digit from g using only, say, the corresponding c⁄b digits from f ?
Note that starting the formula at the first element is the same as performing the standard conversion of a fractional number from b to c, but I want an arbitrary element of the target sequence, in the same way that I can retrieve an arbitrary element of the source.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为没有比连续除以基数并保留余数更简单的方法了。当然,除以任意基数表示的数字也需要线性工作量。
假设 f 代表数字 N,那么基本上
可能不需要显式计算 N,您可以在基数 b 中隐式计算 N。
I don't think there is any easier way than successively dividing by the base and keeping the remainder. Of course dividing number represented in an arbitrary base would require a linear amount of work as well.
Lets say that f represents the number N then basically
It may not be necessary to to compute N explicitly, you could just do it implicitly in the base b.