Simple Code

So you've got 0 to 1023 for 0V to 5V.
And you read 1023

5 x 1023 / 1024 = 4.995

Hmmmm, gotta fix that

No, you've got to accept that.

Imagine a one bit ADC, with a one volt reference.
You apply 750mV.
What's the voltage on the pin?

Answer: the voltage is at least 500mV