Implement a numerically stable number parser

This code operates on pure integers, so it avoids all floating-point pitfalls.