添加base62号码号码

2023-09-11 07:26:41 作者:此夏若空

我说,一个人有一个base62数字(字母:[AABBCC-yYzZ0-9])的char * NUM =ABCD。 用于创建这样一个数字的字母组成的非字母顺序排列的字母! ('A'后'一',而不是'B')的。

Say, one's got a base62 number (alphabet: [aAbBcC-yYzZ0-9]) char *num="abcd". The alphabet used to create such a number consists of letters in non-alphabetical order! ('A' after 'a', not 'b').

如何获得该序列的下一个数字(如何添加1〜base62号)?接下来是ABCE和previous是ABCC。我AP preciate它,如果你给我提供了一些code。

How to get the next number of the sequence (how to add 1 to base62 number)? Next is "abce" and previous is "abcc". I'd appreciate it if you provide me with some code.

推荐答案

要等的如何计算基数N'问题通常,最好的答案的是

从基础-N转换为以2(平凡的,如果ñ== 2 ,很容易   否则),用闪电般的速度快,硬件实现的功能   您的计算机来计算基2,然后从基2转换为   基地-N。

convert from base-N to base-2 (trivial if N==2, easy enough otherwise), use the lightning-fast, hardware-implemented features of your computer to calculate in base-2, then convert from base-2 to base-N.

而拒绝我的荒谬的建议,考虑如何在您的计算机傻瓜,你以为它基于10算术。

While rejecting my absurd suggestion consider how your computer fools you into thinking that it does base-10 arithmetic.

请注意小心,这种做法符合OP严格的指令,以避免将数字转换为基数为10。

Note carefully that this approach complies with OP's strict instruction to avoid converting numbers to base-10.