Adding faster implementation for getDigits.