Remove duplication in number-handling code
Merge pull request #59 from amalloy/perf

Remove duplication in number-handling code