为什么这些基础转换器会给出不同的答案?

Why do these base converters give different answers?

我编写了一个 python 程序来将数字从任何正整数基数转换为另一个基数。

print("Base Converter")
from math import log
print("This converter uses 0-9, followed by A-Z, followed by a-z, giving it individual characters from 0 - 61.")
print("If there are digits greater than 61, each digit will be placed in a pair of vertical lines, eg. 4|A|c|X|63|2|H|144|H.")
def BaseConvert(number, StartBase, EndBase):
    try: # Make sure that the parameters are in the right format
        n = int(str(StartBase)) + int(str(EndBase))
    except ValueError:
        return "Bad Base input"
    StartBase, EndBase = int(StartBase), int(EndBase)
    letters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

    number = str(number)
    for i in number: # Make sure that all the digits are alphanumeric
        if not i.isalnum() and i != "|": # Vertical bars are allowed as they seperate digits greater than 61. Other non alphanumeric characters are not.
            return "Bad input"
    if "|" in number:
        number = number.split("|")
    StartLength = len(number) # Initial length of number
    total = 0 # This will become the final number
    for i in range(StartLength):
        n = StartLength - i - 1 # This effectively reverses the order,
        Digit = number[n]       # going from the last digit in the number (furthest to the right), to the first.
        if Digit in letters:
            Digit = letters.index(Digit) + 10
        try:
            Digit = int(Digit)
        except ValueError:
            return "Bad Number Input"
        if Digit > StartBase:
            return "Bad start base"
        total += int(Digit) * (StartBase ** i)
    number = total
    if EndBase > 1:
        n2 = int(log(number, EndBase)) # Length of result number
    elif EndBase == 1:
        n2 = number
    else:
        print("Unable to complete base conversion")
        return
    total = number
    numbers = []
    J = ""
    for i in range(n2 + 1):
        X = int(total/(EndBase ** (n2 - i))) # Starting from the largest place value, divides the original number (Now in base 10) by the place value
        if X > 9:
            if X < 62:
                X = letters[X - 10]
            else:
                X = str(X)
                J = "|"
        numbers.append(str(X))
        total = total % EndBase ** (n2 - i)
    EndNumber = J.join(numbers)
    return EndNumber
#     Base Conversion Function  /\ /\
#     User input \/ \/ \/ \/ \/ \/ \/
print("Enter your number, start base and end base. (eg. 101101011, 2, 10) ")
inp = "1"
while inp:
    inp = input(">>> ")
    while inp.count(",") != 2:
        if inp == '':
            break
        print("Bad input")
        inp = input(">>> ")
    if inp == '':
        break
    inp = inp.split(",")
    print(BaseConvert(inp[0].strip(), inp[1].strip(), inp[2].strip()))

为了检查我的结果是否正确,我在网上找到了一些基本转换器来测试并插入大量数字,但我注意到不同的计算器给出了不同的结果。

我很确定我的程序是正确的,但我不确定,但我已经进行了几次手动转换,它们与程序相比效果很好,但为什么这些计算器会得到不同的值?

给出以许多 0 结尾的十进制数的站点可能只是 运行 内存不足,或者使用的语言或算法不适用于大数字。请记住,以 36 为基数的第一个 B 已经是以 10 为基数的 4084512220202252076284091826176。鉴于许多人访问网站,他们必须谨慎管理其资源以确保人们不会遇到延迟.该站点很可能只是限制了每个计算可以使用的内存量。

我自己的基础转换器程序的结果:

Ruby Base Converter
Convert from base: 36
Number in base 36: BIGNUMBERTESTEXAMPLE
Convert to base: 10
Base 36: BIGNUMBERTESTEXAMPLE
Base 10: 4274945873844657616917501294866

我的结果与第一个一致。