I think Scheme has a built-in type Bignum for handling arbitrarily large numbers, but if I want to implement it myself how would I do it?
If I am not mistaken it has the following grammar:
|n| = () when n=0
|n| = (r . |q|) where n=qN+r, 0<=r
N = base
r = remainder
q = quotient
E.g. When base N=16, |33| = (1 2) wher 1 is a remainder, 2 is a quotient.
PS: Using bignum implementation how could I go to the next number (successor) and to the previous number (predecessor), such that successor |n| = |n+1| and predecessor |n+1| = |n|
You are in luck. The question is a classic. Andre van Meulebrock has written an excellent series of articles on bignums (representation and related algorithms). The article contains runnable Scheme code, so do experiment with his code.
Head over the archives of MacTech:
http://www.mactech.com/articles/mactech/Vol.08/08.03/BigNums/index.html