ndigits: fix stack overflow when base is not already Int.