You know, I was awake at 2 a.m. this morning thinking about this. First I thought "of course you divide by 1023, that way 1023 comes out at 5V". Then I thought "of course you divide by 1024 because there are 1024 steps".

Then I thought, "if I have $10 in my pocket, half of that is $5, right?" But then I thought, but there are 11 amounts of currency I can have, $0, $1, $2 ... $9, $10. So therefore half of that is 0.5 * 10 / 11, so half of $10 is $4.50". But that's nonsense too!

Then I thought, "maybe you add 1, divide by 1024, and then subtract 1 to compensate". That way 1023 works out. "1023 + 1 = 1024, half of that is 512, subtract 1 again, and we have 511, perfect!". But then I thought of a zero reading. So let's see, you take zero, add 1, divide by 1024, then subtract 1. That's -0.99V! That can't be right!