Factor out doubleDigitValue function.
Compatible with any number of digits