# Collection of code snippets by Arne Vajhøj 
# (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
def toint(s):
    res = int(s)
    return res

def tointx(s):
    res = 0
    for c in s:
        res = 10 * res + (ord(c) - ord('0'))
    return res

def tointxx(s):
    res = 0
    for c in s:
        res = 10 * res + (ord(c) - 48)
    return res

def test(s):
    print('"%s" : %d' % (s, toint(s)))
    print('"%s" : %d' % (s, tointx(s)))
    print('"%s" : %d' % (s, tointxx(s)))

test('1')
test('12')
test('123')
