根据序列和源库确定目标库中的任意数字范围

发布于 2024-09-19 03:24:40 字数 592 浏览 3 评论 0原文

如果我有一个函数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。基数不共享公因数,这意味着在目标基数中表示源基数中的数字所需的位数是小数 (65)。是否可以仅使用相应的 cb 来确定 g 中的单个数字>f 中的数字?

请注意,从第一个元素开始公式与执行小数从 bc 的标准转换相同,但我想要目标序列的任意元素,就像我可以检索源的任意元素一样。

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 (65). Is it possible to determine a single digit from g using only, say, the corresponding cb 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧竹 2024-09-26 03:24:40

我认为没有比连续除以基数并保留余数更简单的方法了。当然,除以任意基数表示的数字也需要线性工作量。

假设 f 代表数字 N,那么基本上

g(1) = N % c;
g(2) = (N / c) % c;
....
....
....

可能不需要显式计算 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

g(1) = N % c;
g(2) = (N / c) % c;
....
....
....

It may not be necessary to to compute N explicitly, you could just do it implicitly in the base b.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文