Question: can uid and gid be the same?
Answer: So, the short answer: no, UID is not always equal to GID. Still, /etc/passwd contains both the UID and GID of the default group on the same line so it's rather easy to extract them.