### AngleLog.BC - logarithmic function that are semi-linear, # changing gradient at each power of the base. # run with funcs.bc ## Specific functions for base 10 # Generate the x-th number in the sequence: # 1,2,3,4,5,6,7,8,9,10,20,30,...,90,100,200,300,...,900,1000,2000,... # e.g. al10(0) = 1 ; al10(11) = 30 define al10(x) { return( (rem(x,9)+1) * 10^int(x/9) ) } # Invert the above # e.g. ial10(50) = 13 ; ial10(1) = 0 define ial10(x) { auto k; k = int(log(10,x)) return( 9*k + x/10^k - 1) } ## Generalised functions for any base b # al(10,x) is equivalent to the above al10(x) define al(b,x) { return( (rem(x,b-1)+1) * b^int(x/(b-1)) ) } # Invert the previous function define ial(b,x) { auto k k = int(log(b,x)) return( (b-1)*k + x/b^k - 1) }