Consolidating repeated code in the Number class