#!/usr/bin/env python3

import math

# floor(log(number)) is almost always the length of this number as string,
# in given base

# this works with the exception if x==1 for base=16 and x<=2 for base=2

def f_hex(x):
    l=len(str(hex(x)[2:]))
    assert math.ceil(math.log(x, 16))==l

def f_bin(x):
    l=len(str(bin(x)[2:]))
    assert math.ceil(math.log(x, 2))==l

def f_dec(x):
    l=len(str(x))
    assert math.ceil(math.log(x, 10))==l

for x in [1234567890,12345678,1234568,123456,1238,18,3]:
    f_hex(x)
    f_bin(x)
    f_dec(x)

