Simple Code

GoForSmoke:
So you've got 0 to 1023 for 0V to 5V.

The converter cannot differentiate between the reference voltage and one quanta less than the reference voltage. In your example that is 5 - 0.0048828125 = 4.9951171875 volts. The last step available to the converter is 4.9951171875 volts to 5 volts. A value of 1023 means the sampled voltage is between 4.9951171875 volts and 5 volts. Your comparison between the two ranges is incomplete because it disregards the fact that one side is discrete (0-1023) and the other side is continuous.

5 x 1023 / 1024 = 4.995

Correct (disregarding the lack of significant digits).

Hmmmm, gotta fix that so how about

There is nothing to fix because dividing by 1024 is not "broken".

You do it your way then

The way the folks at Atmel described it should be done? Of course I'm going to do it that way. They designed the hardware. They spent significantly more time than you and I studying the issues. I am not so arrogant to believe that I posses some hidden wisdom.