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 so how about
5 x (1023 + 1) / 1024 = 5
And you read 0
5 x (0 + 1) / 1024 = .040
Whereas
5 x 1023 / 1023 = 5
5 x 0 / 1023 = 0
You do it your way then