Do not understand what getDig(d) function does